refactor some shit, enable adding user aliases
This commit is contained in:
		
							parent
							
								
									84931ba0d3
								
							
						
					
					
						commit
						7d48ffa35c
					
				
					 5 changed files with 81 additions and 39 deletions
				
			
		
							
								
								
									
										10
									
								
								pgbot
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								pgbot
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -25,8 +25,6 @@ def init(args: list) -> tuple:
 | 
			
		|||
            'bot_session', config['api_id'],
 | 
			
		||||
            config['api_hash']).start(bot_token=config['bot_token'])
 | 
			
		||||
 | 
			
		||||
    # db_conn = pgbotlib.dbstuff.DBConn(
 | 
			
		||||
    #         f'dbname={config['db_name']} user={config['db_user']}')
 | 
			
		||||
    db_conn = pgbotlib.dbstuff.DBConn(config['db_spec'])
 | 
			
		||||
 | 
			
		||||
    return config, db_conn, client
 | 
			
		||||
| 
						 | 
				
			
			@ -35,9 +33,10 @@ def init(args: list) -> tuple:
 | 
			
		|||
def main():
 | 
			
		||||
    config, db_conn, client = init(sys.argv[1:])
 | 
			
		||||
 | 
			
		||||
    responder = pgbotlib.response.Responder(config, client, db_conn)
 | 
			
		||||
    namegen = pgbotlib.misc.NameGenerator(config, db_conn)
 | 
			
		||||
    responder = pgbotlib.response.Responder(config, client, db_conn, namegen)
 | 
			
		||||
    commander = pgbotlib.commands.Commander(config, client, config['admins'],
 | 
			
		||||
                                            db_conn, responder)
 | 
			
		||||
                                            db_conn, namegen, responder)
 | 
			
		||||
 | 
			
		||||
    sched_thread = threading.Thread(
 | 
			
		||||
            target=pgbotlib.sched.spawn_scheduler,
 | 
			
		||||
| 
						 | 
				
			
			@ -47,9 +46,6 @@ def main():
 | 
			
		|||
 | 
			
		||||
    @client.on(telethon.events.NewMessage())
 | 
			
		||||
    async def handle_new_message(event):
 | 
			
		||||
        chat = await event.get_chat()
 | 
			
		||||
        result = await client.get_messages(chat.id, ids=[event.message.reply_to.reply_to_msg_id])
 | 
			
		||||
        print(result)
 | 
			
		||||
        if event.message.text.startswith('/'):
 | 
			
		||||
            await commander.action(event)
 | 
			
		||||
        else:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue