Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # StoryTeller v1.0 by OUTsider <[email protected]>
- # Setup:
- # Change below path to where the stories will rely named story.<2 letter language code>.txt
- set storydir "stories/"
- # To activate:
- # .chanset <channel> +story (DCC)
- #
- # To use:
- # !story <storyname> (PUB) (if paused @/+ to resume)
- # will play the story, if language is ommitted the default (set below) is chosen
- # channel will be +m, requester if not voiced, voiced temporary
- set storydefault "carol1"
- #
- # !pause (PUB) @/+
- # will pause the story, channel will be -m
- #
- # !stop (PUB) @/+
- # stops the story, channel will be -m, requester will loose voice if he didn't have it before play
- #
- # !playspeed <interval in seconds>(PUB) @
- # adjusts the playbackspeed in seconds
- # can also be done using .chanset <channel> story_playspeed <interval in seconds> (DCC)
- setudef flag story
- setudef int story_status
- setudef str story_requester
- setudef int story_playspeed
- setudef int story_line
- if {![info exists storyfile]} {
- set storyfile(dummy) ""
- }
- bind pub - !story story:play
- proc story:play {nick host hand chan args} {
- global storydir storydefault
- if {![channel get $chan story]} {
- return
- }
- if {[channel get $chan story_playspeed] == 0} {
- channel set $chan story_playspeed 6
- }
- set status [channel get $chan story_status]
- switch -- $status {
- 0 {
- set lang [lindex [lindex $args 0] 0]
- if {$lang == ""} {
- set lang $storydefault
- }
- if {![file exists ${storydir}story.$lang.txt]} {
- putserv "NOTICE $nick :The story $lang is not present"
- return
- }
- story:initplay $nick $chan $lang
- return
- }
- 1 {
- putserv "NOTICE $nick :Story in $chan already running"
- return
- }
- 2 {
- if {![isop $nick $chan] && ![isvoice $nick $chan]} {
- return
- }
- pushmode $chan +m
- flushmode $chan
- channel set $chan story_status 1
- story:player $chan
- putserv "NOTICE $nick :Story in $chan resumed"
- return
- }
- }
- }
- bind pub - !pause story:pause
- proc story:pause {nick host hand chan args} {
- if {![isop $nick $chan] && ![isvoice $nick $chan]} {
- return
- }
- switch -- [channel get $chan story_status] {
- 0 {
- putserv "NOTICE $nick :Story not running in $chan"
- return
- }
- 1 {
- channel set $chan story_status 2
- pushmode $chan -m
- flushmode $chan
- putserv "NOTICE $nick :Story paused in $chan"
- return
- }
- 2 {
- putserv "NOTICE $nick :Story already paused in $chan"
- return
- }
- }
- }
- bind pub - !stop story:stop
- proc story:stop {nick host hand chan args} {
- global storyfile
- if {![isop $nick $chan] && ![isvoice $nick $chan]} {
- return
- }
- if {[channel get $chan story_status] == 0} {
- putserv "NOTICE $nick :Story not running in $chan"
- return
- }
- story:end $chan
- putserv "NOTICE $nick :Story stopped in $chan"
- }
- bind pub - !playspeed story:playspeed
- proc story:playspeed {nick host hand chan args} {
- if {![isop $nick $chan]} {
- return
- }
- set args [lindex [lindex $args 0] 0]
- if {![string is integer $args]} {
- putserv "NOTICE $nick :Usage: !playspeed <interval in seconds> (Current: [channel get $chan story_playspeed])"
- return
- }
- channel set $chan story_playspeed $args
- putserv "NOTICE $nick :Playspeed changed to $args seconds"
- return
- }
- bind nick - * story:nickchange
- proc story:nickchange {nick host hand chan newnick} {
- if {[channel get $chan story_requester] == $nick} {
- channel set $chan story_requester $newnick
- }
- }
- bind sign - * story:signpart
- bind part - * story:signpart
- proc story:signpart {nick host hand chan reason} {
- if {[channel get $chan story_requester] == $nick} {
- channel set $chan story_requester ""
- story:end $chan
- }
- }
- proc story:initplay {nick chan lang} {
- global storyfile storydir
- if {[catch {open ${storydir}story.$lang.txt "r"} fp] != 0} {
- putserv "NOTICE $nick :Unable to open ${storydir}story.$lang.txt"
- return
- }
- set storyfile($chan) [split [read -nonewline $fp] "\n"]
- channel set $chan story_status 1
- channel set $chan story_line 0
- pushmode $chan +m
- if {![isvoice $nick $chan] && ![isop $nick $chan]} {
- pushmode $chan +v $nick
- channel set $chan story_requester $nick
- }
- flushmode $chan
- putserv "NOTICE $nick :Enjoy the story"
- story:player $chan
- }
- proc story:player {chan} {
- global storyfile
- if {![channel get $chan story] || [channel get $chan story_status] != 1 || ![info exists storyfile($chan)]} {
- return
- }
- set line [channel get $chan story_line]
- if {[llength $storyfile($chan)] < $line} {
- story:end $chan
- }
- set output [lindex $storyfile($chan) $line]
- putserv "PRIVMSG $chan :$output"
- incr line
- channel set $chan story_line $line
- dotimer [channel get $chan story_playspeed] "story:player $chan"
- }
- proc story:end {chan} {
- global storyfile
- channel set $chan story_status 0
- if {[info exists storyfile($chan)]} {
- unset storyfile($chan)
- }
- if {[isvoice [channel get $chan story_requester] $chan]} {
- pushmode $chan -v [channel get $chan story_requester]
- channel set $chan story_requester ""
- }
- pushmode $chan -m
- flushmode $chan
- }
- proc dotimer {time command} {
- foreach utime [utimers] {
- if {[lindex $utime 1] == $command} {
- killutimer [lindex $utime end]
- }
- }
- return [utimer $time $command]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement