Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (40 sloc) 1.79 KB
import telebot
import pyjokes
import tweepy
TELEBOT_TOKEN = os.environ.get('TELEBOT_TOKEN', '')
TW_CONSUMER_KEY = os.environ.get('TW_CONSUMER_KEY', '')
def start_telebot():
tb = telebot.TeleBot(TELEBOT_TOKEN)
consumer_key = TW_CONSUMER_KEY
consumer_secret = TW_CONSUMER_SECRET
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
#auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
def hello_handler(message):
tb.send_message(, "Hello %s!" % (message.from_user.first_name))
def joke_handler(message):
joke = pyjokes.get_joke(language='en', category='neutral')
tb.send_message(, joke)
def chuck_joke_handler(message):
joke = pyjokes.get_joke(language='en', category='chuck')
tb.send_message(, joke)
def dir_handler(message):
items = ["{} -> {}".format(attr, getattr(message, attr)) for attr in dir(message)]
tb.send_message(, '\n'.join(items))
def get_pycones_handler(message):
status_list ="pycones15", count="10")
status_text = u'\n'.join([st.text for st in status_list])
tb.send_message(, status_text)
#Use none_stop flag let polling will not stop when get new message occur error.
print 'Polling...'
# Interval setup. Sleep 3 secs between request new message.
if __name__ == '__main__':
You can’t perform that action at this time.