Advertisement
kofany

Untitled

Jun 9th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. use Irssi;
  2. use strict;
  3. use vars qw($VERSION %IRSSI);
  4.  
  5. $VERSION = "1.0";
  6. %IRSSI = (
  7. authors => 'Your nick',
  8. contact => 'Your email',
  9. name => 'Idle Reward',
  10. description => 'Gives voice to idle users in #syndykat channel after 120 minutes and announces a reward.',
  11. license => 'License of your choice',
  12. url => 'URL to your script',
  13. );
  14.  
  15. my %idle_users;
  16. my $bot_name = "IdleBot"; # Replace with the name of your bot
  17. my $owner_host = "*!_y\@tahio.eu"; # Replace with the owner's hostmask
  18.  
  19. sub check_idle_users {
  20. my $channel = Irssi::channel_find("#syndykat");
  21.  
  22. foreach my $nick (keys %idle_users) {
  23. my $idle_time = time() - $idle_users{$nick}->{'idle_time'};
  24.  
  25. if ($idle_time >= 7200) {
  26. $channel->command("mode $channel->{'name'} +v $nick");
  27. $channel->printformat(MSGLEVEL_CRAP, 'idle_reward', $nick);
  28. $idle_users{$nick}->{'idle_time'} = time();
  29. }
  30. }
  31. }
  32.  
  33. sub event_public {
  34. my ($server, $msg, $nick, $mask, $target) = @_;
  35.  
  36. if ($target eq "#syndykat") {
  37. if ($mask eq $owner_host && $msg =~ /^!start$/) {
  38. if (!$idle_users{$nick}) {
  39. $idle_users{$nick} = {
  40. 'idle_time' => time()
  41. };
  42. } else {
  43. $idle_users{$nick}->{'idle_time'} = time();
  44. }
  45.  
  46. my $channel = Irssi::channel_find("#syndykat");
  47. $channel->command("mode $channel->{'name'} +v $nick");
  48. $channel->printformat(MSGLEVEL_CRAP, 'idle_start', $nick);
  49. }
  50. }
  51. }
  52.  
  53. Irssi::theme_register([
  54. 'idle_start', 'Start idleC by {nick $0}!'
  55. ]);
  56.  
  57. Irssi::signal_add('message public', 'event_public');
  58. Irssi::timeout_add(60000, 'check_idle_users', undef);
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement