Skip to content

Instantly share code, notes, and snippets.

@hannahherbig
Last active August 3, 2023 04:52
Show Gist options
  • Save hannahherbig/346761 to your computer and use it in GitHub Desktop.
Save hannahherbig/346761 to your computer and use it in GitHub Desktop.
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net -> :[email protected] PRIVMSG #deltabox :.getuser go4it7arh
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- PRIVMSG #deltabox :hannah: Check your notices.
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- NOTICE hannah :Friends : 611
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- NOTICE hannah :Followers : 367
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- NOTICE hannah :Tweets : 9137
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- NOTICE hannah :Status : night
2010-03-28 09:40:38: DeltaBox: irc.deltabox.net <- NOTICE hannah :URL : http://hannah12.net
2010-03-28 09:40:38: Crash. Writing traceback to etc/synarere.tb
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/asyncore.py", line 84, in write
obj.handle_write_event()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/asyncore.py", line 435, in handle_write_event
self.handle_write()
File "/Users/hannah/Desktop/synarere/src/irc.py", line 105, in handle_write
num_sent = self.send(line)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/asyncore.py", line 352, in send
result = self.socket.send(data)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 127: ordinal not in range(128)
2010-03-28 09:40:38: Exiting with code 70: asyncore failure
2010-03-28 09:40:38: Quitting all IRC networks.
[hannah ~/Desktop/synarere] $
"""Twitter module."""
# Import required source module.
from src import commands
import twitter
def cmd_getStatus(conn, (nick, user, host), target, message):
"""Someone asked for a status, so we give it to them."""
api = twitter.Api()
if not message:
conn.sendq.append('PRIVMSG %s :%s: Missing username.' % (target, nick))
return
else:
try:
u = api.GetUser(message)
conn.sendq.append('PRIVMSG %s :%s' % (target, '@' + u.screen_name + ': ' + u.status.text))
except:
conn.sendq.append('PRIVMSG %s :%s: There was an error.' % (target, nick))
def cmd_getUser(conn, (nick, user, host), target, message):
"""Someone asked for a user, so we give it to them."""
api = twitter.Api()
if not message:
conn.sendq.append('PRIVMSG %s :%s: Missing username.' % (target, nick))
return
else:
try:
u = api.GetUser(message)
conn.sendq.append('NOTICE %s :ID : %s' % (nick, u.id))
conn.sendq.append('NOTICE %s :Name : %s' % (nick, u.name))
conn.sendq.append('NOTICE %s :Username : %s' % (nick, u.screen_name))
conn.sendq.append('NOTICE %s :Location : %s' % (nick, u.location))
conn.sendq.append('NOTICE %s :Description : %s' % (nick, u.description))
conn.sendq.append('NOTICE %s :URL : %s' % (nick, u.url))
conn.sendq.append('NOTICE %s :Status : %s' % (nick, u.status.text))
conn.sendq.append('NOTICE %s :Tweets : %s' % (nick, u.statuses_count))
conn.sendq.append('NOTICE %s :Followers : %s' % (nick, u.followers_count))
conn.sendq.append('NOTICE %s :Friends : %s' % (nick, u.friends_count))
conn.sendq.append('PRIVMSG %s :%s: Check your notices.' % (target, nick))
except:
conn.sendq.append('PRIVMSG %s :%s: There was an error.' % (target, nick))
def module_init():
"""
Module entry point. This is used to create commands, attach to
specific IRC events, etc.
"""
commands.create('.getstatus', cmd_getStatus, commands.chan)
commands.create('.getuser', cmd_getUser, commands.chan)
def module_fini():
"""
Module exit point. This is used to destroy commands, detach from
specific IRC events, etc. You MUST do this, or memory will be leaked!
"""
commands.destroy('.getstatus', cmd_getStatus, commands.chan)
commands.destroy('.getuser', cmd_getUser, commands.chan)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment