--------------------------------------------------------- Twitter, Tweets with Megahal v4.31 (Egghelp version) --------------------------------------------------------- Original concept and script by Warlord Copyleft (C) 2010 - speechles (imspeechless@gmail.com) v4.31 - February 28th, 2010 - speechles (#roms-isos@efnet) *copyleft = gnu gpl v3 --------------------------------------------------------- This script acts as your gateway to twitter from IRC and from twitter back to IRC again. It is near-transparent and supports multiple users per account, multiple channels per account. The same as IRC supports multiple users per channel and the IRCD supports multiple channels. The use of accounts is done by creating a link from a channel directly to an account. Once this is done, all users who tweet from within that channel appear as tweets to that channels account. With MegaHAL enabled, your bot will check every so-often and then reply to these users tweets within your profile. This makes your twitter page appear quite unique and unlike any other. This script will also periodically check for new @mentions and relay them directly back to IRC. MegaHAL is also able to chat with anyone who @mentions your accounts. There is a service bot list which controls the bots it shouldn't reply back to. All of the configuration options are explained below so setting this up shouldn't be too hard. But first, let me explain how to obtain the two required pieces you will need. TLS PACKAGE ----------- http://sourceforge.net/projects/tls/files/ You should have no problems finding and installing the appropriate package here. BASE 64 PACKAGE --------------- http://sourceforge.net/projects/tcllib/files/tcllib/1.12/ You DO NOT need to install all of tcllib to merely install Base64. Simply copy the /base64 folder to your /tcl8.x/lib/ folder and it will be detected. If it isn't simply place base64.tcl within your /scripts folder and source it before you source twitter.tcl --------------- READY TO BEGIN? Now onto the more fun part. After you have the two requirements set above accomplished. All you need to do is make sure 23 configuration options are set correctly for your bot. The defaults can be left but they assume everything is "ON" and depending upon your situation, perhaps you should read on and change these 1 by 1 as we go through what these all mean. ----------------------------------------------------------------- This short readme is here to help those having problems installing, using, and creating accounts with this script. I will explain the config here section by section, let's begin: ------------------- 1) Twitter Logo # This is the twitter logo. # (string) set twitter(logo) "\[\002\00311Twitter\002\003]:" It doesn't really matter what you put here as long as you remember that tcl special characters MUST be escaped. This is shown on the example above escaping brackets (\[ & \]). ------------------- 2) Http User Agent # Set user agent. # (string) set twitter(agent) "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)" This also is irrelevant, as everything is done using twitter's RestAPI. Then only part that this is actually relevant is when using the !twitter command. It pretends it is a web browser, and it may break if you change this to omit "Mozzila" here. Experiment if you want ;) ------------------- 3) URL Base # Set the url base # (string) set twitter(url) "http://twitter.com/" At the moment, you shouldn't change this. It doesn't quite work with the other twitter variants (ident.ca and others). So right now leaving this set-in-stone is what you need to. ------------------- 4) Output Style # Set the output style here: # %chan == $chan, %nick == $nick # no other variables can be used # (string) set twitter(output) "PRIVMSG %chan" This isn't much useful except to change it to "NOTICE %nick" or "NOTICE %chan" or even "PRIVMSG %nick". That's about all the variety your really getting the one it mentions and the three I have. Four different ways to set this, choose one as your destiny... ------------------- 5) Output Style # What effect would you like added to twitter numerics? # for example: # effect on "\00304" is red text # effect off "\003" turns off the color # (strings) set twitter(effect-on) "\002" set twitter(effect-off) "\002" This is where you get to be creative, as this is where all the effects such as color, bold, underline come from. effect-on is the codes for (mIRC style) color, bold, underline, or any other effect you can think of. effect-off is the codes required to negate these effects and return the text back to plaintext. You can use "\017" here for now, but in the future there will be a line-wrap function which will work exactly the same as it does presently in the google script. At that point \017 won't cut it, and you will need to tell the script the exact codes required to get back to plaintext. ------------------- 6) Throttle # how many seconds should each user wait before re-issuing # a twitter command? Set this in seconds. # (0 off/1 on) set twitter(throttle) 1 Each command has its own seperate array element, so setting this to 1 allows each user to use each seperate command once in your time period. A setting of 60 would restrict a user to 1 request for each of these :!tweet,!twitter,!myhome,etc,etc ... Only duplicate requests will have this penalty imposed. ------------------- 7) Timelines # timelines - xml is far easier to parse... # you should never need to change these either. # (strings) set twitter(friends) "http://www.twitter.com/statuses/friends_timeline.xml" set twitter(public) "http://www.twitter.com/statuses/public_timeline.xml" set twitter(user) "http://www.twitter.com/statuses/user_timeline.xml" set twitter(home) "http://www.twitter.com/statuses/home_timeline.xml" set twitter(mention) "http://www.twitter.com/statuses/mentions.xml" set twitter(private) "http://twitter.com/direct_messages.xml" Do like it says, don't change these for now. ------------------- 8) Timeline Displays # max amount of timelines to show in channel, this is how many # lines you wish to see for every request. # (integer, preferably less than 5 or 6 or it's spammy) set twitter(friendmax) 4 Set this to the amount of each restapi request you want to see in channel. This includes !myhome, !myprofile, !myfriends, !mymentions and !public. You can always make this less by using ranges with these requests like below: !myhome 1-2 : will only give 2 requests, not the default of 4 shown above !myhome 2 : will start at number 2, and show the default 3 more, ending at 5. There are more examples but experimenting is the best way to use this feature... ------------------- 8) Global Tweet Format # Set the global tweet format here # if no local tweet format is set in the channel acct list below # then the global setting will be used instead. # %nick = $nick # %chan = $chan # %text = user input # %modes = (+ or @) op or voice only presently... # (string) set twitter(globaltweetformat) "<%nick> %text" If your using MegaHAL leave this as it is. The script presently wants this format to correctly deconstruct things for learning and replies. If you don't intend to use MegaHAL then this can be constructed to form anything you like based upon the %variables your allowed for construction. Have fun, be creative. ------------------- 9) Tweet Flags # minimum flags required to issue tweets # (string) set twitter(flags) "vomn|vomn" This controls who can, or who can't make use of the extended features of this script. Anyone can issue !twitter requests, but only those matching these flags can do anything else.. ------------------- 9) Channel Flags # what modes can people temporarily tweet with # these are channel modes, not flags on the bot # you can use op, voice, or both, or "". # (list) set twitter(channel) [list "op" "voice"] This extends (#9 Tweet Flags) to allow the present ops or voices within the channel the ability to use the extended features. ------------------- 10) Auto Arrange @Mentions? # Do you want @mentions within tweets to always # be arranged at the front of the tweet? # !tweet @fred this is kewl @mike do you agree? # is autoarranged like below before !tweeting... # @fred @mike this is kewl do you agree? # (0 no/1 yes) set twitter(autoarrange) 0 This allows you to reference several @usernames within your tweet and have the bot move them all to the front. As you can see in the config comments for this option it gives an example of how this will look. If you want this enabled you want to make sure this is 1, otherwise leave it 0. ------------------- 11) Twitter Accounts # Accts to tweet to # "#channel|Login|Password[|tweet-format]" # -- # Channel name here uses lowercase, your actual # channel case is irrevelant. But here you must # use lowercase only # -- # tweet-format is entirely optional and used as # an optional local over-ride. If no tweet-format # is given the globaltwitterformat will be used. # -- # (list) set twitter(accts) { "#yourchan|youracct|yourpass" "#yourchan-ops|youracct|yourpass" "#yourotherchan|your2ndacct|your2ndpass|<%nick:%chan> %text" "#yourotherchan-ops|your2ndacct|your2ndpass|<%nick> %text" } This is for you to tie your channel to a twitter account. Once that is done you can use that channel as your gateway to twitter and it will gateway twitter back to your irc channel. If multiple channels are linked to an account only the first channel listed will have things relayed in channel. All of them will get updated but only the first will contain relays of this and that is to keep your bot from lagging or excess flooding off the network. There is no limit to the amount you can add here. ------------------- 12) MegaHAL # If you have megahal enabled, then you might want # to set the below option to 1. With this set you # can then use the chanset command: # .chanset #yourchan +twittermega # Now your bot will reply to twitter messages at # set intervals just to keep your account active if # users aren't posting. The bot will not post to the # account if it was the last one to post. # (0 off/1 on) set twitter(megahal) 1 Sometimes just giving users the ability to !tweet things into your twitter account gets boring. You can have your bot also inject things there via MegaHAL just by setting this to 1. After that every so often your bot will read the last tweet from your account and reply to it via MegaHAL. This gives it a presence on your account as if it's a real person and gives personality to your twitter page depending on the personality of your MegaHAL. Using this feature is advised for those who want something unique on twitter to draw followers. ------------------- 13) MegaHAL Time Interval # If your using megahal on your twitter for reply # tweets to your users, what timestring interval # would you like to use? The default string of # "?0*" will check if it can reply every # 10 minutes, at exactly minutes ending with 0. # (string) set twitter(timestring) "?0*" This is the time interval at which the bot will check your accounts to check them and update them with MegaHAL replies. You do not need to change this. It will check every 10 minutes, at every minute ending with 0. ------------------- 14) Silent Megahal # do you want the bot to putlog when it's made # replies? a setting of 1 will post it has in # the channel associated to your account. # (it will only announce in the first channel ) # (linked to your account. if multiple channels) # (are used it won't display it's replied there) # (this would be too spammy and floody... ) # (0 off/1 on) set twitter(silent) 0 Keeping this set to 0 is advised. The bot will then notify you in channel the exact moment it replies to your account with a megahal reply. This gives users in the channel a chance to visit the page and see what it said. They can then possibly follow your account and help you attract users to your irc channel, who knows :P. ------------------- 15) MegaHAL Can Learn # do you want your bot to learn from twitter # tweets from users? # (0 off/1 on) set twitter(learn) 1 Setting this to 1 will allow your bot to learn and integrate what others !tweet to your account as a possible outcome when giving new replies. This is what creates the "intelligence" within artificial-intelligence. Keeping this set to 1 is of course advised at all times. ------------------- 16) Relay Mentions # Do you want @mentions to be relayed directly # to IRC when they occur? # (0 off/1 on) set twitter(usementions) 1 This is something you should also always keep set to 1. Setting it to 0 will require you to issue !mymentions requests to see in the timeline when people have mentioned your accounts. Keeping it at 1 all of this is automatic and I suggest everyone keep this set to 1 as well. ------------------- 17) MegaHAL replies to Mentions # if your using megahal would you like your bot # to also reply to your @mentions? # (0 off/1 on) set twitter(usemegareply) 1 This is where the MegaHAL can reply to literally anyone mentioning one of your accounts as a mention. This is when anyone tweets @yourusername within their text. If you have #15 set to 1, you should also keep this option set to 1. After doing this there is a Special feature present in v4.3 which allows you to ignore certain @usernames when they reply from having the MegaHAL reply to them. These are referred to as service bots. These are bots which reply back to you via twitter and are usually instigated by users in your channel issuing !tweet @username msg-here having the MegaHAL reply to these causes spam for your channel. The commands for adding service bots (basically ignoring users) is as follows: !services : List all service bots attached to an account. +service [list of usernames here] : Adds the usernames to the service bot list for an account. -service [list of usernames here] : Removes the usernames from the service bot list for an account. If * is used. -service * then all entries will be removed. ------------------- 18) MegaHAL learns from your @Mentions # do you want your bot to learn from @mentions # other users send it? # (0 off/1 on) set twitter(mentionlearn) 1 With this set to 1 your bot will learn from any @mention to you accounts. This allows it to appear more intelligent and actually remember what is said to it. Have fun with this and experiment. This is what it's all about.. ;) ------------------- 19) Mentions Time Interval # set the time interval to check for new @mentions # for each acct above? The default string of "?5*" # will check if it can reply every 10 minutes, at # exactly minutes ending with 5. This is so it doesn't # collide with the timer above which posts to users # using !tweet. # (string) set twitter(mentiontimestring) "?5*" This is the time interval at which the bot will check for mentions and possibly reply to them with it's MegaHAL replies. You do not need to change this. It will check every 10 minutes, at every minute ending with 5. ------------------- 20) Mention Limit # set the limit of new @mentions the bot is going # to be replying to each cycle # (integer) set twitter(mentionlimit) 2 Everytime the bot checks for new mentions, how many of the new ones would you like it to announce? It will also attempt to MegaHAL reply to any @username as it announces unless you have added that username to the service bot list which will then merely announce the new mention rather than reply to it as well. This occurs only to those which are in the service bot list, any username which is not and mentions your username if #16 is set to 1 will be replied to. ------------------- 21) Silent mentions # do you want the bot to putlog when the accounts # mentions are gathered and/or megahal replies? # a setting of 0 will post these in the channel # associated to your account. # (it will only announce in the first channel ) # (linked to your account. if multiple channels) # (are used it won't display it's replied there) # (this would be too spammy and floody... ) # (0 channel/1 putlog) set twitter(mentionsilent) 0 It's advised to always keep this set to 0. Setting it to 1 will not announce new mentions in channel or when it has made MegaHAL replies. You will need to check your twitter accounts with !mymentions and !myhome to see conversations that have happened. Leaving this set to 1 allows for near-real-time interactions. ------------------- 22) Save Filename # What filename should we save timelines and serivces # to during rehash and using the timestring found # below this? # (string) set twitter(filesave) "twitter.dat" Put the name you want your eggdrop to save the twitter data as, these are timelines and services. If you want to put this in a specific folder of your eggdrop, use: set twitter(filesave) "\path\here\twitter.dat" The path MUST exist, the script will not create it. If it doesn't exist you will suffer errors. ------------------- 23) Save Time Interval # set the time interval to save timelines and services # for every account. The default string of "30*" will # save every 30 minutes. It will also be saved at # every rehash. set twitter(autosavetimestring) "30*" How often do you want your bot to save it's collected timelines and services? The default will save these every 30 minutes, or every rehash. ******************************************************************************************** Congratulations, you now have yourself a gateway from twitter to IRC. Feel free to: !tweet @suqmuhnutz something @suqmuhnutz is the channel I use. Me, one of our users, or our MegaHAL will reply back to you whenever you do. Enjoy the script, and if you experience any problems let me know. Version 4.31: Supports the following commands: !twitter return a twitter profile page to IRC, any user can do this. !tweet @msg-id @username ] return timelines from your friends, only specific users can do this. Range is optional, it can be X-Y or X. X and Y must be integers. !myprofile [] return timelines from your profile, only specific users can do this. Range is same as !myfriends. !myhome [] return timelines from your home, only specific users can do this. Range is same as !myfriends. !public [] return public timelines, only specific users can do this. Range is same as !myfriends. !mymentions [] return timeslines of your @mentions, only specific users can do this. Range is same as !myfriends. !user [] return usernames tweet timelines, only specifc users can do this. Range is same as !myfriends. !services return the list of service bots associated to your channels account, only specific users can do this. -service removes a service bot, or list of service bots from the list. Only specific users can do this. +service adds a service bot, or list of service bots to the list. Only specific users can do this. ******************************************************************************************** Have a fun, dance like an robot. ;) Last modified: Feb 28th, 2010 by speechles visit http://forum.egghelp.org/viewtopic.php?t=17556 for support and more information.... #eof - now go play with the script... ;)