Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def disconnectmysql(cursor,cnx):
- emp_no = cursor.lastrowid
- cnx.commit()
- cursor.close()
- cnx.close()
- def connectmysql():
- cnx = connection.MySQLConnection(user=usermariadb,
- password=passwordmariadb,
- host=hostmariadb,
- database=databasemariadb)
- cursor=cnx.cursor()
- return cursor, cnx
- @bot.command('richiesta')
- def richiesta_command(chat,message,args):
- sender=message.sender
- cursor, cnx = connectmysql()
- if str(message.text)=="/richiesta":
- text_message="invia la richiesta in questo modo <strong> /richiesta richiesta </strong> "
- else:
- querry="SELECT data_richiesta FROM info_richieste WHERE id_utente_richiedente='"+str(sender.id)+"'order by id_richiesta desc LIMIT 1"
- datatest=' '
- cursor.execute(querry)
- for row in cursor.fetchall():
- datatest=row[0]
- chat.send(str(datatest))
- richiesta=str(message.text[10:])
- querry="INSERT INTO info_richieste (contenuto_richiesta, id_utente_richiedente, status,data_richiesta) VALUES ('"+str(richiesta)+"','"+str(sender.id)+"', 0,'"+str(dt.datetime.now())+"')"
- cursor.execute(querry)
- giorni_attesa=14
- text_message="richiesta: "+richiesta+" effettuata ricordati che non puoi effetuare una nuova richiesta per 2 settimane tranne se lo diciamo noi admin quindi la tua prossima richiesta la potrai fare il "+str(date.fromordinal(date(date.today().year, 1, 1).toordinal() + dt.datetime.today().day +giorni_attesa))
- chat.send(text_message,syntax="HTML")
- text_message="#richiesta \nutente:"+str(sender.name)+"\ncon username:@"+str(sender.username)+"\ned id:"+str(sender.id)+"\na fatto la richiesta:\n"+richiesta+"\nne potrà fare un altra il:"+str(date.fromordinal(date(date.today().year, 1, 1).toordinal() + dt.datetime.today().day +giorni_attesa))+"\ntag:#richiesta"+str(sender.id)
- querry="SELECT idchattg FROM chatsend WHERE tipo=0"
- cursor.execute(querry)
- for row in cursor.fetchall():
- bot.chat(row[0]).send(text_message,syntax="HTML")
- disconnectmysql(cursor,cnx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement