Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help for a dummy... #43

Open
dany250 opened this issue Mar 21, 2016 · 0 comments
Open

help for a dummy... #43

dany250 opened this issue Mar 21, 2016 · 0 comments

Comments

@dany250
Copy link

dany250 commented Mar 21, 2016

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!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant