コード例 #1
0
ファイル: bot.py プロジェクト: jh0ker/welcomebot
            '(https://core.telegram.org/bots/api#formatting-options) ' \
            'is also supported.\n' \
            'Please [rate me](http://storebot.me/bot/jh0ker_welcomebot) :) '
'''
Create database object
Database schema:
<chat_id> -> welcome message
<chat_id>_bye -> goodbye message
<chat_id>_adm -> user id of the user who invited the bot
<chat_id>_lck -> boolean if the bot is locked or unlocked
<chat_id>_quiet -> boolean if the bot is quieted

chats -> list of chat ids where the bot has received messages in.
'''
# Create database object
db = pickledb.load('bot.db', True)

if not db.get('chats'):
    db.set('chats', [])

# Set up logging
root = logging.getLogger()
root.setLevel(logging.INFO)

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger = logging.getLogger(__name__)


@run_async
コード例 #2
0
ファイル: bot.py プロジェクト: obinsc/welcomebot
            ' messages.\n' \
            'Please [rate me](http://storebot.me/bot/examplebot) :) ' \
            'Questions? Message my creator @exampleuser'
'''
Create database object
Database schema:
<chat_id> -> welcome message
<chat_id>_bye -> goodbye message
<chat_id>_adm -> user id of the user who invited the bot
<chat_id>_lck -> boolean if the bot is locked or unlocked
<chat_id>_quiet -> boolean if the bot is quieted

chats -> list of chat ids where the bot has received messages in.
'''
# Create database object
db = pickledb.load('bot.db', True)

if not db.get('chats'):
    db.set('chats', [])

# Set up logging
root = logging.getLogger()
root.setLevel(logging.DEBUG)

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logger = logging.getLogger(__name__)

コード例 #3
0
all_participants = {}

for key, value in c_info.items():
   print('>> client %s creating' % key)

   clients[key] = TelegramClient(*value)
   clients[key].start()

   print('>>>> client %s created' % key)

   dests[key] = clients[key].get_entity(dest)
   all_participants[key] = clients[key].get_participants(sour, aggressive=True)

print('Works!')

db = pickledb.load('clientbot_test.db', True)
 
ind = 0
if not db.get('start'):
    db.set('start', ind)
else:
    ind = int(db.get('start'))
    print('Start from ', ind) 

while True:
        users = {}
        for key, value in all_participants.items():
            users[key] = value[ind]

        for key, value in users.items():
            if value == None: