Skip to content

Instantly share code, notes, and snippets.

@0xv
Created December 16, 2012 12:48
Show Gist options
  • Save 0xv/4306885 to your computer and use it in GitHub Desktop.
Save 0xv/4306885 to your computer and use it in GitHub Desktop.
twitter Module for phenny
"""
twit.py - twitter Module for phenny
Copyright 24-05-2011, 0xv
Licensed under the yogyacarderlink Forum License 2.
thx to #yogyacarderlink #1st
http://yogyacarderlink.web.id | http://ycl.sch.id
follow @0xv @yogyacarderlink
"""
##twitter
import tweepy
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_KEY = ''
ACCESS_SECRET = ''
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
def twit(phenny, input):
msg = input.group(2).encode('utf-8')
if not msg:
return phenny.reply('meh update opo kowe?')
update = api.update_status(msg)
if update:
phenny.reply('updated!!')
twit.commands = ['update']
twit.priority = 'medium'
def mention(phenny, input):
mentions = api.mentions(count=4)
for mention in mentions:
men = '@'+mention.author.screen_name+": "+mention.text.encode('utf-8')+" : "+str(mention.id)
phenny.say(str(men))
mention.commands = ['mention']
mention.priority = 'medium'
def retwit(phenny, input):
idtwit = input.group(2)
if not idtwit:
return phenny.reply('id twitnya mana?')
twit = api.retweet(id=idtwit)
if twit:
phenny.reply('ReTweeted!!')
retwit.commands = ['rt']
retwit.priority = 'medium'
def timline(phenny, input):
user = input.group(2)
if not user:
return phenny.say('mana usernamenya cuk!?')
liat = api.user_timeline(user, count=4)
for lihat in liat:
hasil = '@'+lihat.author.screen_name+": "+lihat.text.encode('utf-8')+" : "+str(lihat.id)
phenny.say(str(hasil))
timline.commands = ['tl']
timline.priority = 'medium'
def delete(phenny, input):
ids = input.group(2)
if not ids:
return phenny.reply('status idnya mana?')
delet = api.destroy_status(id=ids)
if delet:
phenny.reply('deleted!!')
delete.commands = ['del']
delete.priority = 'medium'
def info(phenny, input):
usere = input.group(2)
if not usere:
return phenny.reply('jancok!! user e ndi?')
view = api.get_user(usere)
phenny.say('nama: '+view.name)
phenny.say('picture: '+view.profile_image_url)
phenny.say('location: '+view.location)
phenny.say('description: '+view.description)
phenny.say('url web: '+view.url)
phenny.say('follower: '+str(view.followers_count))
info.commands = ['info']
info.priority = 'medium'
def reply(phenny, input):
bls = api.update_status(status=input.group(3), in_reply_to_status_id=input.group(2))
if bls:
phenny.reply('wes ke kirim cok!!')
reply.rule = (['reply'], r'(#?\S+) (.+)')
reply.priority = 'medium'
#send mention to channel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment