Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: Twitter  (Read 7912 times)

Offline BlackMamba

  • Moderator
  • Full Member
  • *
  • Posts: 55
    • BlackMamba's Blog
Twitter
« on: August 08, 2011, 06:13:30 PM »
This plugin has the following functionality:

1. If somebody got banned or kick this plugin will tweet player name, reason, expiration time, admin name

2. Admin can tweet ingame

3. Tweets from another twitter account can be printed ingame

Download: https://github.com/bmamba/b3-plugin-twitter/zipball/v1.1

You need at least 1.7.x

This plugin is similar to Ban Tweeter.

You can see the result here: http://twitter.com/chiLLUrT (all posts beginning with "Bot:").

Changelog:

v1.0
----

- plugin tweets kicks and bans
- admin can tweet ingame


v1.1
----

- plugin tweets additional information if somebody was banned/kicked:
  - expiration time of the ban
  - admin name
- plugin prints tweets of another twitter account
- Bugfix: b3 changed data for EVT_CLIENT_BAN_TEMP and EVT_CLIENT_BAN
« Last Edit: September 02, 2011, 07:19:31 PM by BlackMamba »

Offline Father Goose

  • Jr. Member
  • **
  • Posts: 16
Re: Twitter
« Reply #1 on: August 23, 2011, 08:16:58 AM »
Greetings BlackMamba and all,

Just got done trying to install and use the twitter plugin for bans on B3 for UrT. An error message in b3.log said:
110822 23:25:39   BOT       Starting Plugin b3twitter
110822 23:25:39   ERROR   STDERR Twitter now requires an oAuth Access Token for API calls.
110822 23:25:39   ERROR   STDERR If your using this library from a command line utility, please
110822 23:25:39   ERROR   STDERR run the the included get_access_token.py tool to generate one


(by the way, this was the same error we got in attempting to use the Ban Tweeter plugin by Bakes)

We fixed this error by putting the username and password of the twitter account into consumer_secret and access_token_secret of the b3twitter.xml file. The B3 would crash if at least those two were not filled in. Not sure what exactly needs to go into these 4 fields, or even if all 4 fields need to have a value put in.
   <settings name="authentication">
      <set name="consumer_key"></set>
      <set name="consumer_secret"></set>
      <set name="access_token"></set>
      <set name="access_token_secret"></set>
   </settings>



The libraries and such are installed correctly it seems.

Any help to solve this and get it working would be appreciated. nice job :D

Offline BlackMamba

  • Moderator
  • Full Member
  • *
  • Posts: 55
    • BlackMamba's Blog
Re: Twitter
« Reply #2 on: August 23, 2011, 10:46:59 PM »
You cannot use your normal login data to access the twitter api. You have to go to
https://dev.twitter.com/apps/new
to create a new application. After creation you have to change the read only mode to read and write and then create the tokens.

Offline BlackMamba

  • Moderator
  • Full Member
  • *
  • Posts: 55
    • BlackMamba's Blog
Re: Twitter
« Reply #3 on: August 27, 2011, 12:15:14 AM »
Some time ago it was possible that applications could using the twitter api. So the apps could write on your twitter account if they knew your username and password. But this is not possible anymore. Now you need four tokens (text strings), two for identifying your app (consumer tokens) and two which allow your app to access your twitter account (access tokens). The gain is that you don't need to give your login data to the app. If you don't want that the app can access your account anymore you can delete the access tokens and don't need to change your password or any tokens for other apps.

I wrote a short tutorial how to get the tokens from twitter:
http://www.bmamba.de/?p=221

Offline Father Goose

  • Jr. Member
  • **
  • Posts: 16
Re: Twitter
« Reply #4 on: September 01, 2011, 08:28:53 AM »
Ah ok. Thanks for that info and we should be set if we get this going.

Offline BlackMamba

  • Moderator
  • Full Member
  • *
  • Posts: 55
    • BlackMamba's Blog
Re: Twitter: New version
« Reply #5 on: September 02, 2011, 07:24:22 PM »
I added a new version (see first post).

The plugin tweets expiration time and admin name additionally. There are some changes from 1.6 to 1.7, thats why the plugin needs to get fixed. As a result you need at least 1.7.0 now.

You can add another twitter account. Tweets from this account will be printed ingame.

GrandPa

  • Guest
Re: Twitter
« Reply #6 on: November 24, 2011, 09:54:23 AM »
BlackMamba - hope you can help

Just loaded your plugin .. Did all the dependencies added the extra modules and set up Twitter API etc

Can Tweet from inside the game with !twitter message

However not seeing any of the Auto Tweets

B3.log Example

111124 08:44:29   CONSOLE   '40:13 tell: GrandPa to GrandPa: !tempban crashtest 1m test'
111124 08:44:29   CONSOLE   '40:13 saytell: 0 0 GrandPa: !tempban crashtest 1m test'
111124 08:44:29   VERBOSE   'Client Found: GrandPa on slot 0'
111124 08:44:29   VERBOSE   'Queueing event Private Message !tempban crashtest 1m test'
111124 08:44:29   VERBOSE   'Parsing Event: Private Message: AdminPlugin'
111124 08:44:29   DEBUG   'AdminPlugin: OnSay handle 7:"!tempban crashtest 1m test"'
111124 08:44:29   DEBUG   'AdminPlugin: Handle command !tempban crashtest 1m test'
111124 08:44:29   VERBOSE   "RCON sending (127.0.0.1:27960) 'clientkick 8'"
111124 08:44:29   CONSOLE   '40:14 ClientDisconnect: 8'
111124 08:44:29   VERBOSE   'Queueing event Client Disconnect 8'
111124 08:44:29   CONSOLE   '40:14 Item: 7 ut_weapon_ump45'
111124 08:44:29   VERBOSE   "RCON sending (127.0.0.1:27960) 'say ^0(^2SkyNet^0)^7: CrashTestDummy^7 was temp banned by GrandPa^7 for 1.0 minute^7 ^7Test Purposes Only'"
111124 08:44:29   VERBOSE   "Queueing event Client Temp Banned {'duration': 1.0, 'admin': <b3.clients.Client object at 0x01CBE510>, 'reason': '^7Test Purposes Only'}"
111124 08:44:29   DEBUG   "Storage: setClientPenalty data {'time_edit': 1322124269, 'keyword': 'test', 'time_expire': 1322124329, 'admin_id': 1, 'reason': '^7Test Purposes Only', 'inactive': 0, 'data': '', 'client_id': 62, 'duration': 1.0, 'time_add': 1322124269, 'type': 'TempBan'}"
111124 08:44:29   VERBOSE   'Parsing Event: Client Disconnect: CtimePlugin'
111124 08:44:29   DEBUG   u'CtimePlugin: CTIME LEFT:'
111124 08:44:29   DEBUG   u'CtimePlugin: CTIME LEFT: Player: CrashTestDummy^7 played this time: 111 sec'
111124 08:44:29   DEBUG   u'CtimePlugin: CTIME LEFT: Player: CrashTestDummy^7 played this time: 0:1:51'
111124 08:44:29   VERBOSE   'Parsing Event: Client Disconnect: PoweradminurtPlugin'
111124 08:44:29   VERBOSE   'Parsing Event: Client Disconnect: DuelPlugin'
111124 08:44:29   DEBUG   'DuelPlugin: client disconnecting : None'
111124 08:44:29   ERROR   'handler DuelPlugin could not handle event Client Disconnect: AttributeError: \'NoneType\' object has no attribute \'var\' [(\'C:\\\\b3-1.7.1\\\\b3\\\\parser.py\', 973, \'handleEvents\', \'hfunc.parseEvent(event)\'), (\'C:\\\\b3-1.7.1\\\\b3\\\\plugin.py\', 158, \'parseEvent\', \'self.onEvent(event)\'), (\'C:\\\\b3-1.7.1\\\\b3\\\\extplugins\\\\duel.py\', 63, \'onEvent\', \'self.onDisconnect(event)\'), (\'C:\\\\b3-1.7.1\\\\b3\\\\extplugins\\\\duel.py\', 75, \'onDisconnect\', "duels = event.client.var(self, \'duelling\', {}).value")]'
111124 08:44:29   VERBOSE   'Parsing Event: Client Temp Banned: B3TwitterPlugin'
111124 08:44:29   DEBUG   "B3TwitterPlugin: select * from penalties where client_id = 62 and type in ('Ban', 'TempBan', 'Kick') order by time_add desc limit 1"
111124 08:44:29   DEBUG   "B3TwitterPlugin: Found at least one row: {'time_edit': 1322124269L, 'keyword': u'test', 'data': u'', 'time_expire': 1322124329L, 'admin_id': 1L, 'reason': u'^7Test Purposes Only', 'inactive': 0, 'client_id': 62L, 'duration': 1L, 'time_add': 1322124269L, 'type': u'TempBan', 'id': 13066L}"
111124 08:44:29   ERROR   "handler B3TwitterPlugin could not handle event Client Temp Banned: AttributeError: 'module' object has no attribute 'getByCID' [('C:\\\\b3-1.7.1\\\\b3\\\\parser.py', 973, 'handleEvents', 'hfunc.parseEvent(event)'), ('C:\\\\b3-1.7.1\\\\b3\\\\plugin.py', 158, 'parseEvent', 'self.onEvent(event)'), ('C:\\\\b3-1.7.1\\\\b3\\\\extplugins\\\\b3twitter.py', 215, 'onEvent', 'admin = b3.clients.getByCID(p.adminId)')]"
111124 08:44:29   VERBOSE   'Parsing Event: Client Temp Banned: SuperadminPlugin'
111124 08:44:29   DEBUG   'formatting time with timezone [GMT], tzOffset : 0'
111124 08:44:30   VERBOSE   "RCON sending (127.0.0.1:27960) 'status'"
111124 08:44:31   VERBOSE   "RCON sending (127.0.0.1:27960) 'tell 0 ^0(^2SkyNet^0)^7: ^3[pm]^7 ^7CrashTestDummy has ^41 ^7past bans'"
111124 08:44:32   VERBOSE   "RCON sending (127.0.0.1:27960) 'tell 4 ^0(^2SkyNet^0)^7: ^3[pm]^7 ^7CrashTestDummy has ^41 ^7past bans'"


Any Ideas ?  Thanks

GrandPa

  • Guest
Re: Twitter
« Reply #7 on: November 24, 2011, 01:01:01 PM »
Update ..

Changed Config to not Look up Admin who did the kick ban and it now works
   <settings name="tweet">
      <set name="tweetonkick">True</set>
      <set name="tweetonbantemp">True</set>
      <set name="tweetonban">True</set>
      <set name="tweetadminname">False</set>
      <set name="tweetexpirationdate">True</set>
   </settings>

Would still like to get the Admin name on the Tweet working .. so help woul dbe appreciated on fixing that

Also spotted in B3.log, although tweeting there is new error reported

111124 11:55:36   DEBUG   "B3TwitterPlugin: select * from penalties where client_id = 62 and type in ('Ban', 'TempBan', 'Kick') order by time_add desc limit 1"
111124 11:55:36   DEBUG   "B3TwitterPlugin: Found at least one row: {'time_edit': 1322135736L, 'keyword': u'test', 'data': u'', 'time_expire': 1322135796L, 'admin_id': 1L, 'reason': u'^7Test Purposes Only', 'inactive': 0, 'client_id': 62L, 'duration': 1L, 'time_add': 1322135736L, 'type': u'TempBan', 'id': 13070L}"
111124 11:55:36   DEBUG   u'B3TwitterPlugin: Tweet: CrashTestDummy was banned  until 24/11/2011, 11:56: Test Purposes Only'
111124 11:55:37   ERROR   'handler B3TwitterPlugin could not handle event Client Temp Banned: NameError: global name \'rmColor\' is not defined [(\'C:\\\\b3-1.7.1\\\\b3\\\\parser.py\', 973, \'handleEvents\', \'hfunc.parseEvent(event)\'), (\'C:\\\\b3-1.7.1\\\\b3\\\\plugin.py\', 158, \'parseEvent\', \'self.onEvent(event)\'), (\'C:\\\\b3-1.7.1\\\\b3\\\\extplugins\\\\b3twitter.py\', 231, \'onEvent\', "status = self._twitterapi.PostUpdate(\'%s\' % rmColor)")]'

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Twitter
« Reply #8 on: November 28, 2011, 05:41:17 AM »
Very nice plugin. I am trying it out on my aIW servers.

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Twitter
« Reply #9 on: November 28, 2011, 05:46:17 AM »
Well, added this just like any other external plugin and I get this error in the b3 log:

Code: [Select]
111127 20:41:56	BOT    	'Loading Plugin #10 b3twitter [C:\\b3\\b3dmc\\b3\\extplugins\\conf\\b3twitter.xml]'
111127 20:41:56 INFO 'Could not load built in plugin b3twitter (No module named b3twitter)'
111127 20:41:56 INFO 'trying external plugin directory : C:\\b3\\b3dmc\\b3\\extplugins'
111127 20:41:56 CRITICAL 'Error loading plugin: No module named twitter'
Traceback (most recent call last):
  File "C:\b3\b3dmc\b3\parser.py", line 604, in loadPlugins
    pluginModule = self.pluginImport(plugins[s]['name'], plugins[s]['path'])
  File "C:\b3\b3dmc\b3\parser.py", line 717, in pluginImport
    return imp.load_module(name, fp, pathname, description)
  File "C:\b3\b3dmc\b3\extplugins\b3twitter.py", line 34, in <module>
    import twitter
ImportError: No module named twitter

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: Twitter
« Reply #10 on: November 28, 2011, 05:18:02 PM »
Did you install the extra libs?
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline BetterDeadThanZed

  • Beta Testers
  • Hero Member
  • *
  • Posts: 681
    • Killin Zeds
Re: Twitter
« Reply #11 on: November 29, 2011, 03:28:32 AM »
Did you install the extra libs?

I didn't see anything about extra libs in the directions.

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: Twitter
« Reply #12 on: November 29, 2011, 04:20:22 AM »
You can TRY installing this in the b3 folder. I don't know if this is what you need, but simple test.

http://code.google.com/p/python-twitter/ and http://pypi.python.org/pypi/simplejson

And this needs a lib from what I can tell, but could be wrong.

Weird it is not in the instructions.
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

Offline johnvaldetine

  • Full Member
  • ***
  • Posts: 75
Re: Twitter
« Reply #13 on: July 10, 2012, 12:28:49 PM »
Can we use this plugin with Windows Standalone B3 Bot?

Offline MordyT

  • Support Hero
  • Hero Member
  • *
  • Posts: 3644
  • Over $300 Donated to B3!
    • MordyT
Re: Twitter
« Reply #14 on: July 12, 2012, 07:24:48 PM »
Can we use this plugin with Windows Standalone B3 Bot?
I think so, as long as you grab the extra libs I posted above.
But I could be wrong. In fact, the more I think about the more I think you need B3 from source (or egg)
Help will be given to those with a b3.log

If drop off the map it is due to RL becoming busy :)

System: Python 2.7.3 - Deb 7 - B3 Source Code - 128MB RAM box (rented at $5 a year) - remote MySQL - Remote Web Services

 


Rate this page +1 at Google Search

anything