Add settings migration when group -> supergroup promotion event discovered

This commit is contained in:
eleksir
2022-12-12 17:10:02 +03:00
parent 7d74a86dad
commit d43cb5995b
3 changed files with 114 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ use Log::Any qw ($log);
use Math::Random::Secure qw (irand);
use Mojo::Base 'Teapot::Bot::Brain';
use BotLib::Admin qw (FortuneToggleList ChanMsgEnabled GreetMsgEnabled GoodbyeMsgEnabled);
use BotLib::Admin qw (FortuneToggleList ChanMsgEnabled GreetMsgEnabled GoodbyeMsgEnabled MigrateSettingsToNewChatID);
use BotLib qw (Command);
use BotLib::Conf qw (LoadConf);
use BotLib::Util qw (trim fmatch BotSleep Highlight IsCensored RandomCommonPhrase);
@@ -99,6 +99,16 @@ sub __on_msg {
my ($self, $msg) = @_;
# chat info
my $chatid;
# Ловим сообщения о миграции.
if ($msg->can ('migrate_to_chat_id') && $msg->can ('migrate_from_chat_id')) {
if (defined ($msg->migrate_from_chat_id) && defined ($msg->migrate_from_chat_id)) {
MigrateSettingsToNewChatID ($msg->migrate_from_chat_id, $msg->migrate_to_chat_id);
}
return;
}
my $chatname = 'Noname chat';
# user sending message info
my ($userid, $username, $fullname, $highlight, $vis_a_vi) = Highlight ($msg);