【问题标题】:Implementing a timer to stop abuse in a socket IRC bot?实现一个计时器来阻止套接字 IRC 机器人中的滥用行为?
【发布时间】:2011-10-06 17:56:30
【问题描述】:

代码:

while True:
    data = irc.recv(4096)
    if data.find('PING') != -1:
        irc.send('PONG '+ data.split() [1] +' \r\n')
    if data.find('!latest') != -1:
        irc.send('PRIVMSG #PwnMyI :\x02Latest Article:\x02 %s, \x02written by\x02 %s \r\n' % (art_name, art_auth))
        irc.send('PRIVMSG #PwnMyI :\x02Description:\x02 %s \r\n' % art_desc)
        irc.send('PRIVMSG #PwnMyI :\x02View Article:\x02 %s \r\n' % art_link)

这是我的机器人的一个 sn-p 代码。其余代码是自定义构建,并拆分为不同的文件,反正你不需要它们。

irc 是套接字连接,send 通过套接字发送数据。我想要做的是实现一个计时功能,这样它每 5 分钟只工作一次。只是为了停止滥用。谁能指出我正确的方向?谢谢。

【问题讨论】:

    标签: python timer irc bots


    【解决方案1】:

    创建最后发送的时间戳变量。当您发布时,请检查最后发送的时间戳是否在特定时间段内。如果是,请不要发帖。如果不是,请发布并使用当前时间进行更新。

    【讨论】:

      猜你喜欢
      • 2011-10-26
      • 1970-01-01
      • 2011-01-24
      • 2012-07-28
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 2020-02-09
      • 2015-01-27
      相关资源
      最近更新 更多