Answer the question
In order to leave comments, you need to log in
'function' object is not iterable, how to solve?
# -*- coding: utf-8 -*-
import sett
import telebot
from telebot import types
import time
bot = telebot.TeleBot(sett.token)
file = open('C:/users.txt', 'r')
newuser = set ()
for line in file:
newuser.add(line.strip())
file.close()
@bot.message_handler(commands=['start'])
def newuser(message):
try:
if not str(message.chat.id) in newuser:
file = open('C:/users.txt', 'a')
file.write(str(message.chat.id) + '\n')
except Exception as e:
print(e)
bot.send_message(sett.admin_id, 'Произошла ошибка, отправьте кодеру!!!\n'+str(e)+'')
@bot.message_handler(commands=['spam'])
def spam(message):
try:
if message.chat.id == sett.admin_id:
for user in newuser:
bot.send_message(user, message.text[message.text.find(' '):])
except Exception as e:
print(e)
bot.send_message(sett.admin_id, 'Произошла ошибка, отправьте кодеру!!!\n'+str(e)+'')
@bot.message_handler(commands=['stats'])
def stats(message):
try:
if message.chat.id == sett.admin_id:
file = open('C:/users.txt', 'r')
bot.send_message(sett.admin_id, 'Пользователей: '+len(file)+'\nАдмин: '+str(sett.admin)+'\nQIWI кошелек: '+str(sett.qiwi)+'\nBTC кошелек: '+str(sett.btc)+'\nОписание\n/начало описания/\n'+str(sett.info)+'/конец описания/')
file.close
except Exception as e:
print(e)
bot.send_message(sett.admin_id, 'Произошла ошибка, отправьте кодеру!!!\n'+str(e)+'')
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
print(e)
time.sleep(50)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question