Fix logging
- Following advice here: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library - Renamed the logger: client -> fbchat - Remove logging_level init parameter from Client - Use print instead of log.info in examples
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from fbchat import log, Client
|
||||
from fbchat import Client
|
||||
from fbchat.models import *
|
||||
|
||||
# Change this to your group id
|
||||
@@ -19,21 +19,21 @@ old_nicknames = {
|
||||
class KeepBot(Client):
|
||||
def onColorChange(self, author_id, new_color, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and old_color != new_color:
|
||||
log.info(
|
||||
print(
|
||||
"{} changed the thread color. It will be changed back".format(author_id)
|
||||
)
|
||||
self.changeThreadColor(old_color, thread_id=thread_id)
|
||||
|
||||
def onEmojiChange(self, author_id, new_emoji, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and new_emoji != old_emoji:
|
||||
log.info(
|
||||
print(
|
||||
"{} changed the thread emoji. It will be changed back".format(author_id)
|
||||
)
|
||||
self.changeThreadEmoji(old_emoji, thread_id=thread_id)
|
||||
|
||||
def onPeopleAdded(self, added_ids, author_id, thread_id, **kwargs):
|
||||
if old_thread_id == thread_id and author_id != self.uid:
|
||||
log.info("{} got added. They will be removed".format(added_ids))
|
||||
print("{} got added. They will be removed".format(added_ids))
|
||||
for added_id in added_ids:
|
||||
self.removeUserFromGroup(added_id, thread_id=thread_id)
|
||||
|
||||
@@ -44,12 +44,12 @@ class KeepBot(Client):
|
||||
and removed_id != self.uid
|
||||
and author_id != self.uid
|
||||
):
|
||||
log.info("{} got removed. They will be re-added".format(removed_id))
|
||||
print("{} got removed. They will be re-added".format(removed_id))
|
||||
self.addUsersToGroup(removed_id, thread_id=thread_id)
|
||||
|
||||
def onTitleChange(self, author_id, new_title, thread_id, thread_type, **kwargs):
|
||||
if old_thread_id == thread_id and old_title != new_title:
|
||||
log.info(
|
||||
print(
|
||||
"{} changed the thread title. It will be changed back".format(author_id)
|
||||
)
|
||||
self.changeThreadTitle(
|
||||
@@ -64,7 +64,7 @@ class KeepBot(Client):
|
||||
and changed_for in old_nicknames
|
||||
and old_nicknames[changed_for] != new_nickname
|
||||
):
|
||||
log.info(
|
||||
print(
|
||||
"{} changed {}'s' nickname. It will be changed back".format(
|
||||
author_id, changed_for
|
||||
)
|
||||
|
Reference in New Issue
Block a user