1 """«Copyright 2021 Boris Daniel»
2 GPL v3 -> licence.txt"""
3 author='Boris Daniel Martinez Millán'
4 email='borisdanielmm@nauta.cu'
8 from include import friendica_u,welcome,admin_id,token
10 raise ValueError('Hubo un error al importar el include.py')
11 from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update,ReplyMarkup,Bot,user
12 from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext, MessageHandler, Filters, CallbackContext
14 from friendica_module import log_friend,logout_friend,publish,notifications
16 import requests,io,random,re,api,crud,datetime,time,telegram
18 #Funcion base, no eliminar
20 bot.send_chat_action(chat_id=chat, action=telegram.ChatAction.TYPING)
22 ua = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101'
24 HEADERS = {'user-agent': ua}
27 es={'help':'''/start - Inicia el bot
29 /help - Muestra este menu
30 /short_url - Un acortador de URLs
32 /login_f - Logeate en tu cuenta de Friendicarg
34 /logout_f - Borra tu cuenta de la base de datos
36 /publish - Publica texto en tu cuenta de Friendica desde el cliente de Telegram''',
37 'pub':'Publicado con exito 😉',
38 'not_l_f':'Usted no esta logueado 😭',#
39 'cha_l_f':'Su contraseña es incorrecta 😧',#
40 'usa_l_f':'Usuario añadido 😎 ',#
41 'usd_l_f':'Usuario eliminado 😭',#
42 'usl_l_f':'Su usuario ya esta regtistrado 😎, para eliminarlo mande el comando /logout_f',#
43 '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',#
44 'log_s_f':'usa esta sintaxis:\n/login_f Usuario contraseña',
49 en={'help':'''/start - Start the bot
51 /help - Show this menu
53 /short_url - A smaller url creator
55 /login_f - Login into your Friendicarg account
57 /logout_f - Delete your account from the database
59 /publish - Publish text into your Friendicarg account with telegram client''',
61 'not_l_f':'You not are logged in 😭',
62 'cha_l_f':'You password is incorrect 😧',
63 'usa_l_f':'User added 😎',
64 'usd_l_f':'User deleted 😭',
65 'usl_l_f':'Your user is registered 😎, for delete this please send me this comand /logout_f',
66 'usu_l_f':'The user or password is incorrect please send me again the comand with the user and password',
67 'log_s_f':'Use this sintax:\n/login_f user password',
70 #Codigo base de todo abajo
71 def return_string(string,lang):
81 x = datetime.datetime.now()
82 hora=int("%s" %x.hour)
90 return str(hora_s)+":%s:%s" % (x.month, x.second)
93 crud.connect("friend_users.db")
94 crud.runcode("""CREATE TABLE users(telegram INT,user STRING,password STRING)""")
102 def start(update:Update, context: CallbackContext) -> None:
103 typing(update.message.chat_id)
105 lan=io.open(update.effective_user.username,"r")
111 update.message.reply_text(welcome[lang])
113 update.message.reply_text(welcome['es'])
115 def sugerir(update:Update, context: CallbackContext) -> None:
116 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
118 lan=io.open(update.effective_user.username,"r")
123 bot.send_message(chat_id=admin_id,text="El personaje: @"+update.effective_user.username+" hizo una sugerencia: "+" ".join(context.args))
124 update.reply_text(return_string('finish',))
126 def help(update:Update, context: CallbackContext) -> None:
127 bot.send_chat_action(chat_id=update.message.chat_id, action=telegram.ChatAction.TYPING)
129 lan=io.open(update.effective_user.username,"r")
134 update.message.reply_text(return_string('help',lang))
137 def set(update:Update, context: CallbackContext) -> None:
138 if update.message.text.replace("/set ","").split(" ")[0]=="language":
139 if "en" in update.message.text.replace("/set ","").split(" "):
140 f=io.open(update.effective_user.username,"w")
143 update.message.reply_text('Sucess')
144 elif "es" in update.message.text.replace("/set ","").split(" "):
145 f=io.open(update.effective_user.username,"w")
148 update.message.reply_text('Exito')
150 update.message.reply_text("You can help sending this comand /contribute\nPuedes contribuir mandando el comando /contribute")
151 if __name__=='__main__':
152 updater=Updater(token=token)
153 dispatcher=updater.dispatcher
154 dispatcher.add_handler(CommandHandler('start', start))
155 dispatcher.add_handler(CommandHandler('sugerencia', sugerir))
156 dispatcher.add_handler(CommandHandler('login_f', log_friend))
157 dispatcher.add_handler(CommandHandler('logout_f', logout_friend))
158 dispatcher.add_handler(CommandHandler('publish', publish))
159 dispatcher.add_handler(CommandHandler('help',help))
160 dispatcher.add_handler(CommandHandler('set',set))
161 dispatcher.add_handler(CommandHandler('notifications',notifications))
163 updater.start_polling()