mirror of
https://github.com/TeamPGM/PagerMaid-Pyro.git
synced 2024-11-26 02:11:07 +00:00
30 lines
929 B
Python
30 lines
929 B
Python
|
from pagermaid import Config
|
||
|
from pagermaid.enums import Client, Message
|
||
|
from pagermaid.hook import Hook
|
||
|
|
||
|
from mixpanel import Mixpanel
|
||
|
|
||
|
|
||
|
mp = Mixpanel(Config.MIXPANEL_API)
|
||
|
|
||
|
|
||
|
@Hook.on_startup()
|
||
|
async def mixpanel_init_id(bot: Client):
|
||
|
me = await bot.get_me()
|
||
|
if me.username:
|
||
|
mp.people_set(str(me.id), {'$first_name': me.first_name, "username": me.username})
|
||
|
else:
|
||
|
mp.people_set(str(me.id), {'$first_name': me.first_name})
|
||
|
|
||
|
|
||
|
@Hook.command_postprocessor()
|
||
|
async def mixpanel_report(bot: Client, message: Message, command):
|
||
|
if not Config.ALLOW_ANALYTIC:
|
||
|
return
|
||
|
me = await bot.get_me()
|
||
|
sender_id = message.from_user.id if message.from_user else ""
|
||
|
sender_id = message.sender_chat.id if message.sender_chat else sender_id
|
||
|
if sender_id < 0 and message.outgoing:
|
||
|
sender_id = me.id
|
||
|
mp.track(str(sender_id), f'Function {command}', {'command': command, "bot_id": me.id})
|