Skip to content

Instantly share code, notes, and snippets.

@Ell
Created May 19, 2011 18:17
Show Gist options
  • Save Ell/981388 to your computer and use it in GitHub Desktop.
Save Ell/981388 to your computer and use it in GitHub Desktop.
import tweepy
from util import hook, http
import simplejson
consumer_key = ""
consumer_secret = ""
key = ""
secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)
api = tweepy.API(auth)
@hook.command(adminonly=True)
def tweet(inp, nick='', chan='', say=None):
message = inp.replace("<@","<")
body = message
message = nick+": "+body
if len(message) >140:
message = message[0:137]+"..."
api.update_status(message)
print "message tweeted."
return("Message sent to http://twitter.com/catteproject")
@hook.command("twitter")
@hook.command
def twitr(inp, nick='', chan='', say=None):
try:
search = api.search(q=inp, local="eng", lang="en")[0]
except:
say("Search returned nothing brosef.")
searchText = search.text
searchUser = search.from_user
searchID = search.id
output = "\x0303%s\x0F :: %s :: \x0314%s\x0F" % (searchUser, searchText, searchID)
try:
say(output)
except IndexError:
say("Search returned nothing brosef.")
@hook.command("twitlast")
@hook.command("lasttweet")
@hook.command
def lasttwit(inp, nick='', chan='', say=None):
try:
search = api.user_timeline(inp)[0]
except:
say("Search returned nothing brochowsky.")
#print dir(search)
name = search.user
nameThing = name.name
output = "\x0303%s\x0F :: %s" % (nameThing, search.text)
say(output)
@hook.command
def mention(inp, nick='', chan='', say=None):
mentionCatte = api.mentions()[0]
#print mentionCatte.text
name = mentionCatte.user
nameThing = name.screen_name
output = "@\x0303%s\x0F :: %s" % (nameThing, mentionCatte.text)
#print dir(name)
say(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment