yukuku / telebot

Telegram Bot starter kit. Very easy to install with Google App Engine.
Apache License 2.0
689 stars 234 forks source link

help for a dummy... #43

Open dany250 opened 8 years ago

dany250 commented 8 years ago

well .. i have no idea on how to send you a msg.. or where ask for help about your project... so sorry if i made something wrong .. writing this msg as issue!!!!

well.. i dont know anything about python... but i know something of php.. mysql.. and visual basic.. so.. i try to understand as best as i can...

well.. right now .. im not stil able to ANSWER... for example : /start

please select a feature from A , B, C ... at this point i cant grab the answer... and i cannot find a tutorial on how TO DO THAT... i tried to do something like that.. but i (obviously) FAILED... this is the "amazing" code i tried....

`import sys import random import traceback import telepot from telepot.delegate import per_chat_id, create_open

def handle(msg): flavor = telepot.flavor(msg) if flavor == 'normal': content_type, chat_type, chat_id = telepot.glance(msg) print 'Normal Message:', content_type, chat_type, chat_id self.sender.sendMessage('MESSAGGIO DI TESTO NORMALE')

class Player(telepot.helper.ChatHandler): def init(self, seed_tuple, timeout): super(Player, self).init(seed_tuple, timeout) self._answer = int('6594')

def open(self, initial_msg, seed): self.sender.sendMessage('Dimmi il tuo pin') return True

def on_chat_message(self, msg): content_type, chat_type, chat_id = telepot.glance(msg)

try:
   guess = int(msg['text'])
except ValueError:
    self.sender.sendMessage('Scusa.. mi aspetto un pin numerico...')
    return

# check the guess against the answer ...
if guess != self._answer:
    self.sender.sendMessage('Pin errato. connessione interrotta')
    self.close()
else:
    self.sender.sendMessage('Pin riconosciuto.!')
    self.sender.sendMessage('Dammi un comando!')
    return False
    def on_chat_message(self, msg):
        content_type, chat_type, chat_id = telepot.glance(msg)
        return True
        try:
          risposta = (msg['text'])
        except ValueError:
           self.sender.sendMessage('erorre sconosciuto')
           return
        if risposta != 'sposta':
           self.sender.sendMessage('non hai scritto sposta')
           self.close()
        else:
           self.sender.sendMessage(' hai scritto sposta')
           self.close()

def on_close(self, exception): if isinstance(exception, telepot.helper.WaitTooLong): self.sender.sendMessage('Tempo scaduto') TOKEN = 'Token....'

bot = telepot.DelegatorBot(TOKEN, [ (per_chat_id(), create_open(Player, timeout=30)), ]) bot.notifyOnMessage(run_forever=True) `

works well till it ask me "dammi un comando".. then when i write "sposta"... it answers me "Scusa.. mi aspetto un pin numerico..."... That's so sad!! please help me to understand how to manage this answers!!!!