Started work on the next version of tipbot #9

Merged
filipnyquist merged 4 commits from next-tipbot into master 2018-07-06 15:52:09 +02:00
filipnyquist commented 2018-07-02 16:16:33 +02:00 (Migrated from github.com)

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:

  • Uses the twit module, which is more up to date than the official one.
  • Allows withdrawing of custom balance
  • Rounds up digits the same way as Discord Tipbot
  • Removes the need of the lbryian keyword
  • Fixes the bot not triggering on large messages
    This will solve, #8 #7 #6 #4 #2 #1

WARNING, this pull needs reviews before being merged in.

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: * Uses the twit module, which is more up to date than the official one. * Allows withdrawing of custom balance * Rounds up digits the same way as Discord Tipbot * Removes the need of the lbryian keyword * Fixes the bot not triggering on large messages This will solve, #8 #7 #6 #4 #2 #1 WARNING, this pull needs reviews before being merged in.
nikooo777 (Migrated from github.com) reviewed 2018-07-02 19:11:44 +02:00
nikooo777 (Migrated from github.com) commented 2018-07-02 16:27:41 +02:00

don't forget to change or parameterize the track value.
also I'd use let rather than var.

don't forget to change or parameterize the track value. also I'd use `let` rather than var.
nikooo777 (Migrated from github.com) commented 2018-07-02 16:31:03 +02:00

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.

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.
nikooo777 (Migrated from github.com) reviewed 2018-07-06 12:50:04 +02:00
nikooo777 (Migrated from github.com) left a comment

Generally the PR is good!
I added a few suggestions and comments that you can either discard or accept :)

Generally the PR is good! I added a few suggestions and comments that you can either discard or accept :)
nikooo777 (Migrated from github.com) commented 2018-07-06 12:09:04 +02:00

I don't think this is needed, is it?

I don't think this is needed, is it?
nikooo777 (Migrated from github.com) commented 2018-07-06 12:16:52 +02:00

...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.

...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.
nikooo777 (Migrated from github.com) commented 2018-07-06 12:18:35 +02:00

terms is missing

`terms` is missing
nikooo777 (Migrated from github.com) commented 2018-07-06 12:20:53 +02:00

My 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.

My 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.`
nikooo777 (Migrated from github.com) commented 2018-07-06 12:35:30 +02:00

You tried tipping more than you have! You are ${amount-balanceFromUser} LBC short.

`You tried tipping more than you have! You are ${amount-balanceFromUser} LBC short.`
nikooo777 (Migrated from github.com) commented 2018-07-06 12:36:56 +02:00

I think it'd be nice to add a link to the explorer here (short if possible?)

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(" ");
nikooo777 (Migrated from github.com) commented 2018-07-06 12:16:01 +02:00

splitting produces an array, however the length of the array is never checked.

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))}.`,
nikooo777 (Migrated from github.com) commented 2018-07-06 12:25:51 +02:00

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)

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);
nikooo777 (Migrated from github.com) commented 2018-07-06 12:28:24 +02:00

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

`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;
nikooo777 (Migrated from github.com) commented 2018-07-06 12:29:15 +02:00

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 were 0?

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 were `0`?
nikooo777 (Migrated from github.com) commented 2018-07-06 12:30:00 +02:00

ah nevermind i just saw the null check. that works too

ah nevermind i just saw the null check. that works too
nikooo777 (Migrated from github.com) commented 2018-07-06 12:43:17 +02:00

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?

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);
nikooo777 (Migrated from github.com) commented 2018-07-06 12:40:06 +02:00

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?

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?
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:20:47 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:20:47 +02:00

Correct, as i look through the library i can now see that it is not needed

Correct, as i look through the library i can now see that it is not needed
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:21:16 +02:00
@ -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(" ");
filipnyquist (Migrated from github.com) commented 2018-07-06 14:21:16 +02:00

I´ll add a check so that it contains atleast two items, the mention and the trigger word

I´ll add a check so that it contains atleast two items, the mention and the trigger word
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:26:02 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:26:02 +02:00

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.

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.
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:33:26 +02:00
@ -0,0 +82,4 @@
async function getAddress(userId) {
try {
let uAddresses = await lbry.getAddressesByAccount(userId);
filipnyquist (Migrated from github.com) commented 2018-07-06 14:33:25 +02:00

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)

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)
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:35:11 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:35:11 +02:00

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

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
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:36:47 +02:00
@ -0,0 +82,4 @@
async function getAddress(userId) {
try {
let uAddresses = await lbry.getAddressesByAccount(userId);
filipnyquist (Migrated from github.com) commented 2018-07-06 14:36:46 +02:00

So yep, it is there to generate adresses(accounts) for users not having an account already.

So yep, it is there to generate adresses(accounts) for users not having an account already.
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:37:08 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:37:08 +02:00

Will fix!

Will fix!
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:37:15 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:37:15 +02:00

Will fix!

Will fix!
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:37:19 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:37:19 +02:00

Added!

Added!
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:37:26 +02:00
filipnyquist (Migrated from github.com) commented 2018-07-06 14:37:26 +02:00

Check added!

Check added!
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:37:39 +02:00
@ -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))}.`,
filipnyquist (Migrated from github.com) commented 2018-07-06 14:37:39 +02:00

Sounds like a cool idea, adding it to an issue

Sounds like a cool idea, adding it to an issue
filipnyquist (Migrated from github.com) reviewed 2018-07-06 14:38:08 +02:00
@ -0,0 +218,4 @@
function getValidatedAmount(amount) {
amount = amount.trim();
if (amount.toLowerCase().endsWith("lbc")) {
amount = amount.substring(0, amount.length - 3);
filipnyquist (Migrated from github.com) commented 2018-07-06 14:38:07 +02:00

Would probably work, want to keep it like this for now, as this function is the same in the discord tipbot :)

Would probably work, want to keep it like this for now, as this function is the same in the discord tipbot :)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/twitter-tipbot#9
No description provided.