Ejemplo n.º 1
0
 def __init__(self):
     self.usrdir = usrdir
     self.lingua = lingua
     defal = modArgona.Argo()
     self.database = defal.database
     chatdata = self.database.get('chat')
     chatdata.update({'chatid': auth.id()})
     chatdata.update({'content_type': 'text'})
     self.setti = Setting
     self.veces = 0
     self.keywo = ''
Ejemplo n.º 2
0
def handle(msg):
    content_type, chat_type, chat_id = telepot.glance(msg)
    datetime = str(msg['date'])
    datetimeInt=msg['date']
    print(content_type, chat_type, chat_id, datetime)
    moda=externa.check("mode",chat_id)

    if moda == "":
        externa.change("mode","none",chat_id)

    if auth.admin(chat_id):
        if content_type == 'text':
            if msg['text']=="/help":
                helpmsg=externa.msg("tsrmd-help")
                bot.sendMessage(chat_id, helpmsg)

            elif msg['text']=="/start":
                startmsg=externa.msg("tsrmd-start")
                bot.sendMessage(chat_id,startmsg)

            elif msg['text']=="/mode":
                bot.sendMessage(chat_id,"Current mode is \""+moda+"\"")

            elif msg['text']=="/quit":
                externa.change("mode","none",chat_id)
                bot.sendMessage(chat_id,"Successfully quit mode from \""+moda+"\"")

            elif msg['text']=="/temp":
                os.system("/opt/vc/bin/vcgencmd measure_temp>./database/temp")
                bot.sendMessage(chat_id,open("./database/temp").read())

            elif msg['text']=="/admin":
                bot.sendMessage(chat_id,auth.check().read())

            elif msg['text']=="/restart":
                #remsg=externa.msg("tsrmd-restart")
                #bot.sendMessage(chat_id, remsg)
                os.system("setsid ./restart.sh "+target)
            #elif msg['text']=="/re-":
            #    target=msg['text'].split("-")[1]
            #    os.system("setsid ./restart.sh "+target)

            else:
                bot.sendMessage(chat_id, "No action, Original message:\n\""+msg['text']+"\"")
        elif content_type == 'document':
            if msg["document"]["file_name"] == "bin.tar.gz":
                os.system("rm bin.tar.gz")
                bot.download_file(msg["document"]["file_id"],"./bin.tar.gz")
                bot.sendMessage(auth.id(), "Admin is updating Server ")
                os.system("setsid ./upgrade.sh")
    else:
        bot.sendMessage(chat_id, "No action, No response")
Ejemplo n.º 3
0
            elif msg['text']=="/restart":
                #remsg=externa.msg("tsrmd-restart")
                #bot.sendMessage(chat_id, remsg)
                os.system("setsid ./restart.sh "+target)
            #elif msg['text']=="/re-":
            #    target=msg['text'].split("-")[1]
            #    os.system("setsid ./restart.sh "+target)

            else:
                bot.sendMessage(chat_id, "No action, Original message:\n\""+msg['text']+"\"")
        elif content_type == 'document':
            if msg["document"]["file_name"] == "bin.tar.gz":
                os.system("rm bin.tar.gz")
                bot.download_file(msg["document"]["file_id"],"./bin.tar.gz")
                bot.sendMessage(auth.id(), "Admin is updating Server ")
                os.system("setsid ./upgrade.sh")
    else:
        bot.sendMessage(chat_id, "No action, No response")
TOKEN = sys.argv[1]  # get token from command-line

bot = telepot.Bot(TOKEN)
bot.message_loop(handle)
#
bot.sendMessage(auth.id(), "Server Starting")
print ('Listening ...')

# Keep the program running.
while 1:
    time.sleep(10)
Ejemplo n.º 4
0
import auth, time

from core import tool
from core import modDatabase

import modSearch, modArgona

from modHandle import Hande
from modExcute import Excut
from msgMain import MsgMain
from msgShort import MsgShort

usrdir = 'database/usr/' + str(auth.id())
Setting = modDatabase.openSetting(usrdir=usrdir)
lingua = Setting.get('lingua', 'enMY')
msgMain = MsgMain(lingua)


class argo:
    def sending(self, primo='', submo='', mesag=['']):
        msgShort = MsgShort(self.lingua)
        outputes = '\n[output{' + primo + ':' + submo + '}]'
        for wuerd in mesag:
            if len(wuerd) >= 4069:
                parta = [wuerd[i:i + 4000] for i in range(0, len(wuerd), 4000)]
                for numo in range(0, len(parta)):
                    if numo == 0:
                        sentes = outputes + parta[numo] + msgShort.spitpost
                        print(sentes)
                    elif numo == len(parta) - 1:
                        sentes = outputes + msgShort.spitpre + parta[numo]
Ejemplo n.º 5
0
 def on__idle(self, event):  # Timeout Region
     usrdir = 'database/usr/' + str(
         self.argo.database.get('chat', {}).get('chatid', auth.id()))
     lingua = modDatabase.openSetting(usrdir=usrdir).get('lingua', 'enMY')
     self.sending(mesag=[msgMain.timesout + msgShort.cof])
     self.close()