1 """«Copyright 2021 Boris Daniel»
2 GPL v3 -> licence.txt"""
3 author='Boris Daniel Martinez Millán'
4 email='borisdanielmm@nauta.cu'
5 name='Reisub-Bot -> Friendicarg'
7 from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update,ReplyMarkup,Bot,user
8 from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext, MessageHandler, Filters, CallbackContext
9 import api,crud,re,io,telegram
10 token="1531348810:AAG_ZWBHHPI4qxjeWvyWOwwy3xPXsN_2KJ0"
13 es={'pub':'Publicado con exito 😉',
14 'not_l_f':'Usted no esta logueado 😭',
15 'cha_l_f':'Su contraseña es incorrecta 😧',
16 'usa_l_f':'Usuario añadido 😎 ',
17 'usd_l_f':'Usuario eliminado 😭',
18 'usl_l_f':'Su usuario ya esta registrado 😎, para eliminarlo mande el comando /logout_f',
19 'usu_l_f':'El usuario o la contraseña esta mal,por favor enviame de nuevo el comando con el usuario y la contraseña',
20 'log_s_f':'usa esta sintaxis:\n/login_f Usuario contraseña',
21 'cls_l_f':'Tu publicación es muy pequeña o no tiene contenido'}
23 'not_l_f':'You not are logged in 😭',
24 'cha_l_f':'You password is incorrect 😧',
25 'usa_l_f':'User added 😎',
26 'usd_l_f':'User deleted 😭',
27 'usl_l_f':'Your user is registered 😎, for delete this please send me this comand /logout_f',
28 'usu_l_f':'The user or password is incorrect please send me again the comand with the user and password',
29 'welcome':'Hello and welcome to the Reisub Bot',
30 'thiss':'This bot contains some advancend functions of Reisub',
31 'suge':'This user: {} send a sugestion: {}',
32 'urown':'Please give me a link',
33 'urow1':'The link was created',
34 'log_s_f':'Use this sintax:\n/login_f user password',
35 'cls_l_f':'Your publication is clear or very short'}
37 def return_string(string,lang):
45 def log_friend(update: Update, context: CallbackContext) -> None:
47 lan=io.open(update.effective_user.username,"r")
52 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
54 if len(context.args)<=1:
55 update.message.reply_text(return_string('log_s_f',lang))
58 friend=api.FriendApi("https://friendicarg.nsupdate.info/",context.args[0],context.args[1])
59 crud.connect("friend_users.db")
60 if len(crud.read("users","telegram",update.message.chat_id))==0:
61 crud.create("users","'"+str(update.message.chat_id)+"','"+context.args[0]+"','"+context.args[1]+"'")
62 update.message.reply_text(return_string('usa_l_f',lang))
64 update.message.reply_text(return_string('usl_l_f',lang))
65 crud.save();crud.close()
67 update.message.reply_text(return_string('usu_l_f',lang))
68 context.bot.delete_message(chat_id = update.message.chat_id, message_id = update.message.message_id)
70 def logout_friend(update: Update, context: CallbackContext) -> None:
72 lan=io.open(update.effective_user.username,"r")
77 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
78 crud.connect("friend_users.db")
79 if len(crud.read("users","telegram",update.message.chat_id))==1:
80 crud.delete("users","telegram",str(update.message.chat_id))
83 update.message.reply_text(return_string('usd_l_f',lang))
85 update.message.reply_text(return_string('not_l_f',lang))
86 def publish(update: Update, context: CallbackContext) -> None:
88 lan=io.open(update.effective_user.username,"r")
93 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
95 crud.connect("friend_users.db")
96 r=crud.read("users","telegram",update.message.chat_id)
99 if '-' in str(update.message.chat_id):
100 print('LOGGING DEBUG: RUNNING IN A GROUP, if this work please remove the line 93 of the code')
101 friend=api.FriendApi("https://friendicarg.nsupdate.info/",r[0][1],r[0][2])
102 contexto=update.message.text
103 rex=re.findall("#!.*!#",contexto)
105 rex=rex[0].replace("#!","").replace("!#","")
108 a=re.findall('<.*>',contexto)
111 contexto=contexto.replace(i,'[attachment type="link" url="'+i.replace("<","").replace(">","")+'"][/attachment]')
113 a=re.findall('&.*&',contexto)
116 contexto=contexto.replace(i,'[img='+i.replace("&","")+'][/img]')
117 if "!horacu!" in contexto or "!horacu!" in rex:
119 rex.replace("!horacu!",horacuvar)
120 contexto.replace("!hora!",horavar).replace("!horacu!",horacuvar)
121 if "!hora!" in contexto or "!hora!" in rex:
122 horavar=time.strftime('%H:%M:%S')
123 contexto.replace("!hora!",horavar).replace("!horacu!",horacuvar)
124 rex.replace("!hora!",horavar)
125 friend.share(rex,contexto.replace(rex,'').replace('/publish','')+"\n#telegram")
126 update.message.reply_text(rex+'\n'+contexto.replace('/publish@reisub_bot','').replace('/publish ','').replace('#!'+rex+'!#',''))
127 context.bot.delete_message(chat_id = update.message.chat_id, message_id = update.message.message_id)
129 friend=api.FriendApi("https://friendicarg.nsupdate.info/",r[0][1],r[0][2])
130 contexto=update.message.text
131 rex=re.findall("#!.*!#",contexto)
133 rex=rex[0].replace("#!","").replace("!#","")
136 a=re.findall('<.*>',contexto)
139 contexto=contexto.replace(i,'[attachment type="link" url="'+i.replace("<","").replace(">","")+'"][/attachment]')
141 a=re.findall('&.*&',contexto)
144 contexto=contexto.replace(i,'[img='+i.replace("&","")+'][/img]')
145 if "!horacu!" in contexto or "!horacu!" in rex:
147 rex.replace("!horacu!",horacuvar)
148 contexto.replace("!hora!",horavar).replace("!horacu!",horacuvar)
149 if "!hora!" in contexto or "!hora!" in rex:
150 horavar=time.strftime('%H:%M:%S')
151 contexto.replace("!hora!",horavar).replace("!horacu!",horacuvar)
152 rex.replace("!hora!",horavar)
153 friend.share(rex,(contexto.replace(rex,'').replace('/publish','')+"\n#telegram").replace('#!','').replace('!#',''))
154 update.message.reply_text(return_string('pub',lang))
156 update.message.reply_text(return_string('cha_l_f',lang))
158 update.message.reply_text(return_string('not_l_f',lang))
159 def notifications(update:Update,context:CallbackContext):
161 lan=io.open(update.effective_user.username,"r")
166 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
167 crud.connect("friend_users.db")
168 r=crud.read("users","telegram",update.message.chat_id)
170 friend=api.FriendApi("https://friendicarg.nsupdate.info/",r[0][1],r[0][2])
171 update.message.reply_text(friend.notifications(5))
173 update.message.reply_text(return_string('not_l_f',lang))
175 def get_5(update:Update,context:CallbackContext):
177 lan=io.open(update.effective_user.username,"r")
182 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
183 crud.connect("friend_users.db")
184 r=crud.read("users","telegram",update.message.chat_id)
186 friend=api.FriendApi("https://friendicarg.nsupdate.info/",r[0][1],r[0][2])
188 update.message.reply_text(friend.network(5)[i].replace('><i class=icon-link icon-large><span class=sr-only',''))
190 update.message.reply_text(return_string('not_l_f',lang))