Commit 859a3c36 authored by root's avatar root

Encoding str

parent f988e99c
......@@ -126,7 +126,7 @@ class Bot(ABC):
try:
num = randint(0,10)
if num == 0:
file = open("Media/meme-errors.jpg", "rb")
file = open("Media/meme-errors.jpg", "rb", encoding="utf8")
update.reply_photo(photo=file)
except Exception:
logging.error("Cannot send error-meme!")
......
......@@ -31,6 +31,19 @@ from Bot.bot import Bot
class QuizzBot(Bot):
_ALLOWED_EXTENSIONS = ["jpg", "jpeg", "png"]
_EMOJIS = {
"thunderstorm": u'\U0001F4A8',
"drizzle": u'\U0001F4A7',
"rain": u'\U00002614',
"snowflake": u'\U00002744',
"snowman": u'\U000026C4',
"atmosphere": u'\U0001F301',
"clearSky": u'\U00002600',
"fewClouds": u'\U000026C5',
"clouds": u'\U00002601',
"hot": u'\U0001F525',
"defaultEmoji": u'\U0001F300'
}
_admins = []
_groups = None
......@@ -244,6 +257,11 @@ class QuizzBot(Bot):
def elect_quizmaster(self, chat_member):
print() #TODO
def flag(self, country_code):
offset = 127462 - ord('A')
code = country_code.upper()
return chr(ord(code[0]) + offset) + chr(ord(code[1]) + offset)
"""
Static
"""
......
""" Just add goup chat to db, remember that. """
from sys import stdout
from DB.base import Base
from Model.user import User
from sqlalchemy import Column, Integer, BigInteger, String, Boolean, ForeignKey
......@@ -23,12 +23,15 @@ class Chat(Base):
@staticmethod
def create_from_tg(tg_chat, arg1=None, arg2=None):
# Normalisize
title = str(tg_chat.title).encode(stdout.encoding, errors="replace")
description = str(tg_chat.description).encode(stdout.encoding, errors="replace")
# chat_id dont have to be set
return Chat(
id=tg_chat.id,
username=tg_chat.username,
ctype=tg_chat.type,
title=tg_chat.title,
description=tg_chat.description,
title=title,
description=description,
invite_link=tg_chat.invite_link,
sticker_set=tg_chat.sticker_set_name)
\ No newline at end of file
import datetime
from sys import stdout
from DB.base import Base
from Model.chat import Chat
from Model.user import User
......@@ -18,6 +19,8 @@ class Message(Base):
@staticmethod
def create_from_tg(tg_message, chat_id=None, user_id=None):
# Normalisize
text = str(tg_message.text).encode(stdout.encoding, errors="replace")
# message_id dont have to be set
try:
date = tg_message.date.strftime("%m/%d/%Y,%H:%M:%S")
......@@ -25,7 +28,7 @@ class Message(Base):
date = tg_message.date
return Message(
id=tg_message.message_id,
text=tg_message.text,
text=text,
date=str(date),
chat_id=chat_id,
user_id=user_id)
\ No newline at end of file
from sys import stdout
from DB.base import Base
from Model.user import User
from Model.poll_option import PollOption
......@@ -22,12 +23,14 @@ class Poll(Base):
@staticmethod
def create_from_tg(tg_poll, user_id, date=None):
# Normalisize
question = str(tg_poll.question).encode(stdout.encoding, errors="replace")
#options = [Option.create_from_tg(o) for o in tg_poll.options]
#correct_option = (o for o in options if o.id == tg_poll.correct_option_id)
return Poll(
id=tg_poll.id,
ptype=None,
date=date,
question=tg_poll.question,
question=question,
is_closed=tg_poll.is_closed,
user_id=user_id)
\ No newline at end of file
from sys import stdout
from DB.base import Base
from sqlalchemy import Column, Integer, String, BigInteger, Boolean, ForeignKey
from sqlalchemy.orm import relationship
......@@ -17,7 +18,9 @@ class PollOption(Base):
@staticmethod
def create_from_tg(tg_option, poll_id, arg2=None):
# Normalisize
text = str(tg_option.text).encode(stdout.encoding, errors="replace")
return PollOption(
text=tg_option.text,
text=text,
voter_count=tg_option.voter_count,
poll_id=poll_id)
\ No newline at end of file
from sys import stdout
from DB.base import Base
from sqlalchemy import Column, Integer, String, BigInteger, Boolean, ForeignKey
from sqlalchemy.orm import relationship
......@@ -22,12 +23,17 @@ class User(Base):
@staticmethod
def create_from_tg(tg_user, arg1=None, arg2=None):
# Normalisize
username = str(tg_user.username).encode(stdout.encoding, errors="replace")
name = str(tg_user.name).encode(stdout.encoding, errors="replace")
first_name = str(tg_user.first_name).encode(stdout.encoding, errors="replace")
last_name = str(tg_user.last_name).encode(stdout.encoding, errors="replace")
# user_id dont have to be set
return User(
id=tg_user.id,
name=tg_user.name,
username=tg_user.username,
first_name=tg_user.first_name,
last_name=tg_user.last_name,
name=name,
username=username,
first_name=first_name,
last_name=last_name,
link=tg_user.link,
is_bot=tg_user.is_bot)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment