Twitter Retweet Rewards


#1

As we continue to implement features that folks have been for, we are proud to announce retweet rewards are coming soon, and, as always, you can choose to try out the Nightly Build and test the feature out ahead of the next stable release.

The following commands are available:

!twitter set reward - Display the usage in chat.
!twitter set reward toggle [on/off] - Toggle rewards off and on.
!twitter set reward announce [on/off] - Toggle announcing rewards in chat.
!twitter set reward points [points] - Set the reward amount.
!twitter set reward cooldown [hours] - Number of hours to wait between another retweet reward.
!twitter register [username] - Register your Twitter ID (username) for rewards
!twitter unregister - Unregister your Twitter ID (username)

Yes, users must have registered their Twitter ID (username) with your bot. As not everyone uses a Twitter ID that matches their Twitch ID, this option is provided.

You are probably wondering how the cooldown works and why. To prevent users from going through all of your posts and retweeting everything possible to farm points, you have the option of setting a length of time, in hours, that must pass before a user is eligible for a reward again. Note that 0 is allowed and fractions are allowed. For example, 0.5 would be 30 minutes. While we do not recommend using 0 as the cooldown, you may choose to do so.

Note that retweets are polled from Twitter for the amount of time that !twitter set polldelay retweets is set to, the default is 60 seconds.

When multiple people perform a retweet during a poll period, announcements are turned on, and they are eligible for a reward based on the cooldown, the names are listed in one announcement. This reduces the amount of spam in chat.

This feature is fully configurable via the Panel as well on the Twitter tab.


Need help with twitter retweet rewards
Can I have some help with the twitter rewards
#2

This a great idea but is this for retweeting anything or a particular tweet?
Eg !rewardtweet this is the tweet that should be retweeted with link

And then if successfully tweeted then that tweet ID becomes the tweet that gets retweet rewards and link to the tweet gets shown in announcement

Or any old tweet that gets retweeted within the cool down gets the reward?

I ask because there are a number of automatic tweets sent by various services that I don’t necessarily want retweeted but raffle announcements and stream promo tweets are the kind of things I want retweeted


#3

Any retweet that is new enough to not already have been scanned and stored by the Twitter API. In order to stay within Twitter Developer Guidelines, we scan for retweets on a timed basis, and then bump up the value of the last retweet seen. Otherwise, we are scanning all retweets constantly, which is bad. This does not retweet anything in stream, it only rewards folks that do retweet that are detected by the Twitter API and that are registered with your bot - as said above:

Yes, users must have registered their Twitter ID (username) with your bot. As not everyone uses a Twitter ID that matches their Twitch ID, this option is provided.

If you wanted this to handle a specific Tweet then you will need to figure out the Twitter API to retrieve the code Twitter uses to assign to a Tweet, something like 860239657459740672. Then read up on the object for retweets and see which method lets you scan for that ID in the object that is returned from Twitter when pulling back retweets.

You mention any old tweet, this is why the cooldown, to ensure that viewers are not gaming the system by retweeting everything you have as quickly as possible for a reward. Each user has a time period that must pass before they can be rewarded again, and mentioned in chat (if you enable announcements).

You can enable retweets to display in stream, that option has always been there. That is separate from this. This feature is for rewards, not for posting the retweeted content. Please see !twitter set poll retweets and !twitter set polldelay retweets if you want to see retweets in chat.


#4

To show an example:

retweettest illusionaryone illusionarybot
[06-17-2017 @ 02:55:23.416 MDT] >> Sending retweet test event
[06-17-2017 @ 02:55:23.435 MDT] [MUTED] Retweets from illusionaryone, illusionarybot! Reward of 100 bits given!
retweettest illusionaryone illusionarybot testuser
[06-17-2017 @ 02:55:30.127 MDT] >> Sending retweet test event
[06-17-2017 @ 02:55:30.138 MDT] [MUTED] Retweets from testuser! Reward of 100 bits given!

If the first two users retweet a second time within the cooldown period, they are not rewarded and not announced (I have announcements on). However, testuser (who registered) is rewarded the second time. If any non registered IDs come in, they are ignored as well:

retweettest unknownid
[06-17-2017 @ 02:57:07.796 MDT] >> Sending retweet test event
retweettest asdfsajfasjdkflajsfd
[06-17-2017 @ 02:57:13.955 MDT] >> Sending retweet test event

I believe in the past people have asked for the retweet rewards, I did indicate that this has to be implemented fairly carefully and always has the potential for some kind of abuse. This is the simplest design that I could come up with to help prevent such abuse.


#5

And here is it working if I retweet myself with retweets turned on and reward announcements turned on:

[06-17-2017 @ 03:05:48.670 MDT] [MUTED] [Twitter Feed From @IllusionaryOne] RT @IllusionaryOne: Spaces. https://t.co/ZejwKxfkvq [https://goo.gl/6YpBe2]
[06-17-2017 @ 03:06:34.787 MDT] [MUTED] [Twitter Feed From @IllusionaryOne] Spaces. https://t.co/ZejwKxfkvq [https://goo.gl/bTD5zR]   <-- note this shows up because I posted on my own timeline....
[06-17-2017 @ 03:06:34.798 MDT] [MUTED] Retweets from illusionaryone! Reward of 100 bits given!
mods
[06-17-2017 @ 03:09:52.809 MDT] [MUTED] @IllusionaryBot, Mods in channel: illusionarybot
[06-17-2017 @ 03:09:55.392 MDT] [MUTED] [Twitter Feed From @IllusionaryOne] RT @IllusionaryOne: Got a might warm today. https://t.co/GePV6FDOQO [https://goo.gl/gaX1mG]
mods
[06-17-2017 @ 03:10:09.640 MDT] [MUTED] @IllusionaryBot, Mods in channel: illusionarybot
mods
[06-17-2017 @ 03:10:33.327 MDT] [MUTED] @IllusionaryBot, Mods in channel: illusionarybot

Hopefully this helps. Personally, I have always left the retweets off. Some people turn that feature on though. The rewards feature is just a way for a streamer to thank viewers that register their Twitter IDs for thinking about them.


#6

yes I can see the logistics problem with scanning for the tweet id in retweets rather than for a specific time period. I accept and fully endorse your logic captain!

I think wanting to only get particular tweets retweeted may be a bit anal, perhaps. :smiley:

I’ll compile the nightly and give it a test today.

thanks for continuing to add new features and fix old ones !!

Loony


#7

just a bit of feedback, I got rewarded for my own tweet

after testing today, it didn’t pick up retweets but just my own mentions. I will test some more

11:03 Ban Timeout  Moderator  loonycrewbot: [Twitter Feed From @loonygeekfun ] you can now register your twitter username and get rewarded when you retweet my tweets! just type !twitter… https://t.co/DcVZ2VApfz [ https://goo.gl/nG3oj1 ]
11:03 Ban Timeout  Moderator  loonycrewbot: Retweets from loonygeekfun ! Reward of 100 Loons given!

#8

After doing a few hours testing and switching off mentions polling , it seems that only my own tweets were being rewarded . Multiple people registered their usernames and retweeted my tweets but did the get the reward


#9

You should, you registered that Twitter ID for rewards. That won’t change.

You will need to provide debug logs for the others that are not getting rewards. I need to see if the events are firing.


#10

this is my log from today in events log, what else should I look at?

[06-17-2017 @ 09:32:31.663 GMT] [init.js:739] Core loaded, initializing bot...
[06-17-2017 @ 09:32:32.945 GMT] [init.js:1339] init.js api's loaded.
[06-17-2017 @ 09:32:57.047 GMT] [donationHandler.js:40] Donation announcements enabled
[06-17-2017 @ 11:04:24.238 GMT] [raffleSystem.js:366] A raffle was opened by: loonycrewbot. Arguments (open 250 loonything 0 -followers -usepoints)
[06-17-2017 @ 11:11:02.788 GMT] [raffleSystem.js:375] A raffle was closed by: loonycrewbot.
[06-17-2017 @ 11:41:53.654 GMT] [twitterHandler.js:551] Sent Auto Update to Twitter
[06-17-2017 @ 11:56:53.067 GMT] [raffleSystem.js:366] A raffle was opened by: loonycrewbot. Arguments (open 250 loonything 0 -followers -usepoints)
[06-17-2017 @ 11:58:42.011 GMT] [raffleSystem.js:375] A raffle was closed by: loonycrewbot.
[06-17-2017 @ 12:21:49.315 GMT] [raffleSystem.js:366] A raffle was opened by: loonycrewbot. Arguments (open 250 loonything 0 -followers -usepoints)
[06-17-2017 @ 12:24:44.773 GMT] [raffleSystem.js:375] A raffle was closed by: loonycrewbot.
[06-17-2017 @ 12:43:13.757 GMT] [twitterHandler.js:551] Sent Auto Update to Twitter
[06-17-2017 @ 13:44:33.612 GMT] [twitterHandler.js:551] Sent Auto Update to Twitter
[06-17-2017 @ 14:04:57.025 GMT] [streamInfo.js:419] loonycrewbot changed the current status to party pack with viewers (clean) [uk/eng]
[06-17-2017 @ 14:05:08.424 GMT] [streamInfo.js:387] loonycrewbot changed the current game to The Jackbox Party Pack 2
[06-17-2017 @ 14:45:53.775 GMT] [twitterHandler.js:551] Sent Auto Update to Twitter
[06-17-2017 @ 18:08:11.924 GMT] [init.js:739] Core loaded, initializing bot...
[06-17-2017 @ 18:08:13.230 GMT] [init.js:1339] init.js api's loaded.
[06-17-2017 @ 18:08:36.367 GMT] [donationHandler.js:40] Donation announcements enabled
[06-17-2017 @ 18:09:18.160 GMT] [streamInfo.js:419] loonycrewbot changed the current status to bring the missions [uk/eng]
[06-17-2017 @ 18:09:30.854 GMT] [streamInfo.js:387] loonycrewbot changed the current game to The Elder Scrolls V: Skyrim
[06-17-2017 @ 19:09:34.085 GMT] [twitterHandler.js:551] Sent Auto Update to Twitter

#11

Not what I need, so, I will have to try to reproduce your error. No ETA. If anything, I will remove the feature for now and provide no further support for it.


#12

I sprinkled some debug log lines in the script and it came out with this. It seems that event.getUserNameArray() is returning all the same username
logs/event/

[06-18-2017 @ 08:59:40.391 GMT] [init.js:739] Core loaded, initializing bot...
[06-18-2017 @ 08:59:41.286 GMT] [init.js:1339] init.js api's loaded.
[06-18-2017 @ 09:00:05.072 GMT] [donationHandler.js:40] Donation announcements enabled
[06-18-2017 @ 09:00:05.251 GMT] [twitterHandler.js:61] retweet bind 1
[06-18-2017 @ 09:00:05.252 GMT] [twitterHandler.js:70] retweet bind 2
[06-18-2017 @ 09:00:05.253 GMT] [twitterHandler.js:80] retweet bind 3 
array = LoonyGeekFun,LoonyGeekFun,LoonyGeekFun,LoonyGeekFun
[06-18-2017 @ 09:00:05.274 GMT] [twitterHandler.js:96] retweet bind 4

based on this code

/**
     * @event twitterRetweet
     */
    $.bind('twitterRetweet', function(event) {
      $.log.event('retweet bind 1');
        if (!$.bot.isModuleEnabled('./handlers/twitterHandler.js')) {
            return;
        }

        /* The core only generates this event if reward_toggle is enabled, therefore, we do not check the toggle here. */
        if ($.getIniDbNumber('twitter', 'reward_points') == 0) {
            return;
        }
      $.log.event('retweet bind 2');
        var userNameArray = event.getUserNameArray(),
            i,
            twitterUserName,
            rewardNameArray = [],
            lastRetweet,
            reward = $.getIniDbNumber('twitter', 'reward_points'),
            cooldown = $.getIniDbFloat('twitter', 'reward_cooldown') * 3.6e6,
            now = $.systemTime();

      $.log.event('retweet bind 3 array = '+userNameArray.join(","));

        for (i in userNameArray) {
            twitterUserName = userNameArray[i].toLowerCase();
            userName = $.inidb.GetKeyByValue('twitter_mapping', '', twitterUserName);
            if (userName === null) {
                continue;
            }

            lastRetweet = $.getIniDbNumber('twitter_user_last_retweet', userName, 0);
            if (now - lastRetweet > cooldown) {
                rewardNameArray.push(userName);
                $.inidb.incr('points', userName, reward);
                $.setIniDbNumber('twitter_user_last_retweet', userName, now);
            }
        }
    $.log.event('retweet bind 4');
        if (rewardNameArray.length > 0 && $.getIniDbBoolean('twitter', 'reward_announce')) {
            $.say($.lang.get('twitter.reward.announcement', rewardNameArray.join(', '), $.getPointsString(reward)));
        }
    });

I tried looking for getUserNameArray but couldn’t find where it populates the array. I have the source but still couldn’t find where it gets those values so I couldn’t see what is going on that might cause that


#13

I looked into this yesterday and yes, the Twitter API is not returning what it seems it should. I disabled the pagination and had it dump the JSON from the Core for me and noticed it that way. I will need to rearchitect a chunk of this (find a different API call) that will resolve the issue.

Thanks for looking into it as well!

Cheers


#14

it seems to detect that there are retweets and how many

perhaps the username of the owner of the tweet being retweeted is being selected instead of the username of the person doing the retweet?

where in the source is this code? I couldn’t find where getUserNameArray is populated in the source folder anywhere.


#15

This has been moved to a pull request to be reviewed and merged. There is a different end point for getting information about retweets (including the names of the folks that retweeted). The caveat to this, Twitter only allows 75 pulls every 15 minutes. As such this is currently being ran at a forced interval (I hit my rate limit last night during testing, the error dumps were plentiful).

Each one of those pulls, per Tweet, does pull back up to 100 users that retweeted. So, if multiple people do perform a retweet, we should hopefully see those in one request. Also, Twitter only returns the 20 most recent retweets through the API without walking the user story wall (not going to do that due to rate limits - and again, 75 is the max in 15 minutes, so, even if you had a large amount of retweets, they can’t be queried). So, this will limit what can pull back to first come, first serve. Unfortunately, there isn’t anything I can do to circumvent the Twitter API rate limits.

I said many months ago that this would probably never entirely cover everyone nor provide perfect protection for rewards, we are forced to work within the confines of the Twitter API limits, and that still stands.


#16

If a Twitch user who is not on Discord registers their Twitter ID, will the points awarded to that Twitch user sync to their Discord profile once connected or are they separate?


#17

The point system in Discord links to the point system on the Twitch side. So, once they sync their Twitch ID, points should sync up. They both use the same database tables.

Thanks


#18

[06-23-2017 @ 10:35:13.027 GMT] [CHAT] Retweets from twotonegamer! Reward of 100 Loons given!

it’s picking up other users but only 1 at a time now on latest nightly 2.3.7.1 build fd7edee


#19

This patch will be coming in tonight – it was grabbing their user name (via GetUserName()) and not their @twitterName (via GetScreenName() – oddly, I thought UserName was login ID and ScreenName was the displayed name, but I was wrong) so was probably missing people:

In other words this:
[NotIllusionaryOne, ScaniaTV, NotIllusionaryOne, NotIllusionaryOne, PhantomCombo (Alex), SGTShotYou :globe_with_meridians:, Coco, NanaSalva [TeEm], PWNY Retweets, Zackery M., NanaSalva [TeEm], Coco, SGTShotYou :globe_with_meridians:, ZazelRoyal #GS, Toad22484, ScaniaTV, Third Half, Third Half, Rachel Akau, Rachel Akau, Rachel Akau, ZazelRoyal #GS, Rachel Akau, Kame’s Klassiks, ZazelRoyal #GS, Rachel Akau, ZazelRoyal #GS, Rachel Akau, Khryztoepher]

Needed to be this:

[NotIllusionary1, ScaniaTV, NotIllusionary1, NotIllusionary1, PhantomIndex, SGTShotYou, SGTcocopop, NanasSalvatore, PWNYretweets, Zelakto, NanasSalvatore, SGTcocopop, SGTShotYou, QueenEvilness, Toad22484, ScaniaTV, TheThreeTwo, TheThreeTwo, ilimakitty, ilimakitty, ilimakitty, QueenEvilness, ilimakitty, KameKlassiks, QueenEvilness, ilimakitty, QueenEvilness, ilimakitty, CTG9580]

[06-23-2017 @ 10:34:46.824 MDT] [CHAT] Retweets from notillusionary1, queenevilness, ilimakitty, ctg9580! Reward of 100 points given!

I just put in their twitter IDs as mapped into my bot, rather than what they would be called in my actual chat on my test channel. I didn’t add everyone either. One thing I might have to come back and look at is chopping the output string and leaving people off, there is a max limit in Twitch as to high long a message can be.


#20

I’m having an issue with v7. 1 with the Twitter integration where after I connected it it spams discord and twitch chat with all the past posts and retwetes