Started work on the next version of tipbot #9
No reviewers
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
dependencies
Epic
good first issue
hacktoberfest
help wanted
icebox
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/twitter-tipbot#9
Loading…
Reference in a new issue
No description provided.
Delete branch "next-tipbot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While working on the issues in the repo i found that the source code had a lot of extra stuff not needed for the tipbot to work, i´ve rewritten most of the functions and cleaned up the code.
This pull:
This will solve, #8 #7 #6 #4 #2 #1
WARNING, this pull needs reviews before being merged in.
don't forget to change or parameterize the track value.
also I'd use
let
rather than var.3 is a magic number here in the sense that I have no clue what it is. I guess that it's not a problem on webstorm if it shows the parameter name, but worth keeping in mind that from outside the IDE it might not be easy to read.
Generally the PR is good!
I added a few suggestions and comments that you can either discard or accept :)
I don't think this is needed, is it?
...thus if the split didn't go right, there is a chance that the bot crashes on this line as the array doesn't have at least 2 entries.
I would suggest adding a check somewhere in-between.
terms
is missingMy English isn't exceptional but I think the sentence should be changed to:
Under no circumstances shall LBRY Inc. be held responsible for lost, stolen or misdirected funds.
You tried tipping more than you have! You are ${amount-balanceFromUser} LBC short.
I think it'd be nice to add a link to the explorer here (short if possible?)
@ -0,0 +42,4 @@
stream.on("tweet", function(tweet) {
if(tweet.user.screen_name === config.get("bot.handle").substring(1)) return;
let msg = checkTrunc(tweet);
msg = msg.slice(msg.indexOf(config.get("bot.handle"))).split(" ");
splitting produces an array, however the length of the array is never checked.
@ -0,0 +123,4 @@
async function doDeposit(tweet, msg) {
try {
const post = await T.post("statuses/update", {
status: `@${tweet.user.screen_name} Your deposit address is ${await getAddress(id(tweet.user.id_str))}.`,
Just a wild suggestion. Do you think integrating a QR to the tweet could be a cool thing to do? we could use an API like this one: https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=bT7cCPUauRkuFvCNq8Fn1NkmuDMVBL768e (notice the address appended)
@ -0,0 +218,4 @@
function getValidatedAmount(amount) {
amount = amount.trim();
if (amount.toLowerCase().endsWith("lbc")) {
amount = amount.substring(0, amount.length - 3);
amount = amint.split("lbc")[0];
probably works too without having to worry too much about spaces or anything after "lbc".Though it would have to be tested
@ -0,0 +220,4 @@
if (amount.toLowerCase().endsWith("lbc")) {
amount = amount.substring(0, amount.length - 3);
}
return amount.match(/^[0-9]+(\.[0-9]+)?$/) ? amount : null;
if you return
null
how is that going to impact the originall call? Can it handle a null value? would it be better if it were0
?ah nevermind i just saw the null check. that works too
you're catching the error here, but what happens if something doesn't go right? Will a tip go through and fail along the process somewhere?
@ -0,0 +82,4 @@
async function getAddress(userId) {
try {
let uAddresses = await lbry.getAddressesByAccount(userId);
i'm slightly confused. Is this function supposed to generate addresses for users that were tipped but didn't yet have an account to their user?
Correct, as i look through the library i can now see that it is not needed
@ -0,0 +42,4 @@
stream.on("tweet", function(tweet) {
if(tweet.user.screen_name === config.get("bot.handle").substring(1)) return;
let msg = checkTrunc(tweet);
msg = msg.slice(msg.indexOf(config.get("bot.handle"))).split(" ");
I´ll add a check so that it contains atleast two items, the mention and the trigger word
The tipping here is internally, which means it just moves the amount between the accounts, this helps us skip fees. So the coins shows up directly in the other persons wallet.
@ -0,0 +82,4 @@
async function getAddress(userId) {
try {
let uAddresses = await lbry.getAddressesByAccount(userId);
That function is there to assure that the user has a tipping account in the new format, as the user needs that for the bot to be able to move over from the old account to the new account.(This function follows the new id format instead of username)
It should probably not be catched there, instead it should throw an error in the main loop, making it impossible to try and send coins over to a non existing account
@ -0,0 +82,4 @@
async function getAddress(userId) {
try {
let uAddresses = await lbry.getAddressesByAccount(userId);
So yep, it is there to generate adresses(accounts) for users not having an account already.
Will fix!
Will fix!
Added!
Check added!
@ -0,0 +123,4 @@
async function doDeposit(tweet, msg) {
try {
const post = await T.post("statuses/update", {
status: `@${tweet.user.screen_name} Your deposit address is ${await getAddress(id(tweet.user.id_str))}.`,
Sounds like a cool idea, adding it to an issue
@ -0,0 +218,4 @@
function getValidatedAmount(amount) {
amount = amount.trim();
if (amount.toLowerCase().endsWith("lbc")) {
amount = amount.substring(0, amount.length - 3);
Would probably work, want to keep it like this for now, as this function is the same in the discord tipbot :)